Weekend Laravel Improvements

Taylor Otwell
2 min readApr 1, 2017

--

This week as I was working on a fresh application idea a couple of “paper cuts” in Laravel jumped out at me. I like to think of framework paper cuts as small things that can be easily fixed to improve developer experience.

Exception Rendering

The first paper cut I noticed was exception rendering. Some of you may have been forced to create if statements like the following within your exception handler’s render method:

If you have many types of custom exceptions and responses, these if statements can become tedious. So, in Laravel 5.5 you may simply define a render method directly on the exception:

Job Chaining

The second paper cut I encountered was the need to run several queued jobs in sequence, where each job only dispatches if the one before it finishes successfully. This behavior is already possible if you manually dispatch each job from the handle method of its previous job, but I don’t like that approach because it makes the jobs aware that they are being chained. I don’t want any jobs to be aware they are being chained and I want to have total freedom to re-arrange the order of the jobs or add new jobs without modifying the jobs themselves.

So, for Laravel 5.5, I’ve implemented the ability to do this very easily using a new chain method when dispatching a job:

Hopefully you enjoy these new features! Let me know if you encounter any other “paper cuts”!

--

--