Laravel 5.5: What’s new?

Despite being an open source PHP framework, Laravel has constantly evolved to meet emerging trends in web application development. The latest Long Term Support (LTS) version of Laravel was officially released in August. Laravel 5.5 allows developers to speed up web application development by leveraging PHP 7.

At the same time, it comes with several new features, improvements, and bug fixes to simplify the development of custom web applications. Developers can automate the migration process from Laravel 5.4 to Laravel 5.5 using third-party tools like Laravel 5.5 Shift. But it’s also important for PHP programmers to understand the new features and changes in Laravel 5.5.

Summary of new features and changes in Laravel 5.5

Automatic package discovery

While working with an older version of Laravel, developers must go the extra mile to add service providers to the application’s configuration file and register the relevant facades. But Laravel 5.5 has the ability to detect service providers and facades automatically. In addition, it registers service providers and facades without requiring any manual intervention.

resource classes

While working with Laravel 5.5, developers can use resource classes to speed up API development. They no longer need to use an additional transformation layer between Eloquent models and JSON requests. Resource classes make it easy for developers to convert models and collections of models to JSON without using a transformation layer.

Automatic Registration of Console Commands

The older version of Laravel requires the developer to list custom commands manually in the kernel console via its $commands property. Laravel 5.5 allows developers to register custom commands more efficiently by calling the new load method from kernel commands. Once the load method is called, it will scan a specific directory for console commands and automatically log any console commands found in the directory.

New frontend preset options

The latest version of Laravel supports basic Vue scaffolding. But it allows developers to take advantage of a number of new frontend presets. Developers can run preset commands to switch from Vue scaffolding to React scaffolding. Similarly, they can use the preset remote CSS and JavaScript scaffolding for the web application. However, the developer can take advantage of these frontend presets only in new Laravel applications.

Validation rule objects

Laravel 5.5 allows developers to add custom validation rules to a web application more efficiently using validation rule objects. A developer can create new validation rules in the app/Rules directory simply by running a new Artisan command. But each object rule can only have two methods: passes and messages. The passes method receives the attribute name and value, while the messages method returns the validation error message.

Time-based work attempts

Laravel allows developers to set the number of times a job or task should be retried before failing. Laravel 5.5 allows developers to add a time period to the number of work attempts. A developer now has the option to set the time for job attempts to abort. Therefore, a job can be attempted within a specific time period.

Renderable Mailings

Older versions of Laravel do not provide any features to simplify email design testing. Therefore, developers must rely on third-party tools like Mailtrap to evaluate email designs. Laravel 5.5 makes it easy for users to test email designs by displaying emails directly in the browser. It even returns emails directly from the routes.

on-demand notifications

Using Laravel 5.5, Laravel developers have the option to have the app send notifications to people who are not stored as users. They can call the new Notification::route method to send on-demand notifications to people by specifying custom ad-hoc notification routing information.

consistent exception handling

While working with older versions of Laravel, developers must customize the format of JSON validation error responses according to specific locations in the PHP framework. Laravel 5.5 allows developers to maintain consistency in handling validation exceptions and avoid customization. Developers can even control the format of the JSON validation error message with a single method.

Renderable and reportable exceptions

In addition to maintaining consistency in exception handling, Laravel 5.5 allows developers to define a render method directly on exceptions. Therefore, developers can include custom response rendering logic in exceptions without putting conditional logic in the event handler. They even have the option to customize the reporting logic for each exception.

cache lock

Laravel 5.5 comes with improved Redis and Memcached cache drivers with the ability to get and release atomic locks. Developers can take advantage of these enhanced cache drivers to get arbitrary locks by calling a simple method. They can use the simple method to get a lock that prevents multiple processes from trying to do the same task before the application does a specific task.

New routing methods

The updated version of Laravel makes it easier for developers to define routes by providing several new methods. Developers can use Route::redirect to easily define a route that redirects to a different URI. Also, the Route::view method makes it easy for developers to define a route that has a view. Programmers can avoid defining a complete path by using the shortcuts provided by these methods.

New database configuration option

Laravel 5.5 allows developers to take advantage of a new database configuration option called sticky while configuring read/write database connections. As an optional value, sticky makes it easy to immediately read records written to the database during the current request cycle. In addition, it allows developers to mix read and write connection operations if write operations are performed on the database during the same request cycle.

Sheet Improvements

While using Laravel, developers speed up view generation and rendering through a robust templating engine like Blade. The latest version of the PHP framework comes with several improvements related to Blade. For example, it allows Laravel developers to define custom conditional directives using Closures through a new method: Blade::if. Similarly, a developer can check the current state of a user more efficiently by using various shortcuts: @auth, @guest, @endauth, and @endguest.

Overall, Laravel 5.5 comes with several new features and improvements. These new features make PHP programmers more productive and reduce the amount of time and effort required to build custom web applications.

Leave a Reply

Your email address will not be published. Required fields are marked *