Laravel Pro Tips
Another day, another Laravel tip.
If you need to catch exceptions and don't want to stop the execution of further code, please make sure you use report(). Make it easy for yourself to log the problems!
#laravel #php #phpc
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! 🤩
Steve Bauman 💎
No articles were found.