What’s New in Laravel 5.4 – Transformation That Took Place

Laravel is again here with its latest update Laravel 5.4.

Let us learn something about unique features of the latest update upon the previous updates. Laravel development has become easier with this update. This update continues the improvements made in Laravel 5.3 by adding support for Notifications and Laravel Dusk.

New Middlewares

With the release of 5.4, two new middlewares are now shipped with the framework:


As the name itself says, trim strings middleware trims the extra space from request data. For an instance, at the time of submitting an email through the form on your website, if a user mistakenly types some extra space post the mail, this middleware tends to trim the whitespace automatically.


This middleware plays an important role in converting empty strings to null. Hence, if the user is submitting an empty form, with this, instead of getting “, it is converted to null.

From Elixir to Mix

Laravel Elixir provided us a process which made the development and asset packaging easier.

Now, in the latest update, Elixir will be changing the underlying system and from then it will be built on web pack instead of earlier used Gulp. This update in Elixir will replace the plugin ecosystem, and due to this change, it will rename the package. This comes with a new helper named mix(), which will serve as a replacement to the former elixir() function.

Fluent Routing

The Rout facade in Laravel will be fluent than it was earlier. Then, if we wanted to name a route, code was something like:

Route::get(‘user/{id}/profile’, function ($id) {
Now, if we want the same thing done, only this is required:
Route::name(‘profile’)->get(‘user/{id}/profile’, function ($id) {
// some closure action…

Components and Slots

Both these elements play an important role in simplifying HTML elements into reusable areas.

We generally make use of components like models, notification panel etc. Now, with this update, it can be defined as components and also reuse them.

For creating a component, We create a new blade file and refer to its using.

Modal text go in here

Real-Time Facades

Facades provide a “static” interface to the classes which are available in the application’s service container. Laravel ships with many such facades that would provide access to almost all the features of Laravel. These serve as “static proxies” to underlying classes of the server container. Also, it provides the benefit of a terse, expressive syntax while maintaining testability and flexibility.

Laravel Dusk

This would provide an user-friendly browser automation and testing API. To use this, you do not need to install JDK or Selenium to your system. Instead of which, dusk will use a standalone chrome driver installation. You can even utilize any selenium compatible driver.

Ultimately, I mean with this, Laravel code can be tested in a similar way to that in a web browser. For now, Laravel uses browser-kit for testing.

The problem with browser-kit is that it is limited, and Dusk serves as an alternative with more features. Dusk can detect AJAX etc.

Higher Order Collection Messages

This latest update supports higher order messaging, which will break down to “collection shortcuts”. What if, instead of filtering a collection, passing a closure, and returning some data, you could simply type:


Resourceful Controllers With Model Boilerplate

When generating a controller from the command line (PHP artisan make: controller), you’ll now find a new –model flag. When called with the name of a model, Laravel will automatically generate a resourceful controller that includes the necessary boilerplate to inject this model in all relevant controller actions.

These updates may help you with better results. Learn them properly and make your work easier. Keep coding!

Interested & Talk More?

Let's brew something together!

WhatsApp Image