Laravel Pro Tips
Use Laravel's rescue() helper function instead of try / catch with an empty catch block when you want to ignore an expected exception (and avoid ugly code).
Shawn 🤦🏻♂️ Lindstrom
🌶️ #Laravel Tip: I like to use the helper functions `abort`, `abort_if`, `abort_unless` to throw HTTP Exceptions.
There is also `throw_if` and `throw_unless` to throw a RuntimeException in your code.
#PHP #Developers #100Devs
Bilal Haidar - Available 4 Laravel gigs
Quick @laravelphp tip: Trying to figure out what is causing an error that isn't in your logs (e.g. a 404)?
Temporarily override the `$internalDontReport` array in your exception handler to allow any exceptions to be reported. Run the request again and check your laravel.log
Gilbert Pellegrom 🍋
💡 A nice, undocumented feature of @laravelphp: you can “map” exceptions from one type to another in your exception handler. Nice for converting “domain” exceptions to a more appropriate HTTP exception #Laravel
If you're creating custom exceptions inside your Laravel application, you can add a "context()" method to provide additional data to be printed in the log, as well as a "render()" method to allow the exception to display its own view to the user. Super cool! 🤩
No articles were found.