Laravel 5.5 Updates And What It Means For The Developers

January 5, 2018

Laravel 5.5, released on 30th August 2017, is the current stable version of the popular open-source PHP web framework. It requires PHP 7.0+, which includes speed improvements that will decrease the CPU load by about half, along with developer features for operation. The 5.5 version offers bug fixes for 2 years and security updates for 3 years making it the much-needed LTS (Long Term Support) release since the two-year window of Laravel 5.1 bug fix benefits has come to an end.

The major updates of this version are as follows:

1. Introduces The migrate:fresh Command

The new php artisan migrate:fresh command works similar to the migrate:refresh command. However, while migrate:refresh rolls back all the migrations, migrate:fresh drops all tables and run the existing migrations from scratch. This new command is most useful when working with foreign key constraints or when you have a down() method in the migration that has not been well defined.

2. Introduces Three Front-end Presets

  • Bootstrap
  • Vue
  • React

By default, the preset is set at Vue and can be changed to React or Bootstrap.
We can change the preset to react using the command php artisan preset react. Or if you don’t want to work with any of the front-end scaffolding, use the command php artisan preset none.

3. Enables Automatic Package Discovery

Up until now, using a third-party package in Laravel projects meant having to instal the package, register its service providers and add the aliases through the package’s composer.json file. Laravel 5.5 makes the process much simpler with its automatic package discovery feature. If the package has been configured for auto discovery, you will be able to use in on the fly! Similarly, when you uninstall a package, the auto discovery feature will remove the service providers and facades in the config/app.php file.

4. A Streamlined Request Validation Process

Laravel 5.5 has made two major changes to the request feature.
1. You can directly create objects from the validated data–you no longer need controlled validator but can instead call the validator on your Request instance.
2. You can store the data returned by the validator in a variable and pass on to the create method of the model.

5. Whoops Makes A Return!

The return of Whoops! simplifies the error debugging process to a large extent. It not only points out the exact line of the code which caused the error and marks a stack trace to the error with a screenshot, but also allows direct access to the reference files in the editor or IDE–the PHP-source files should be locally accessible for this feature. You also have quick access to all the set environmental variables and icons that allow error search through Google, StackOverflow or DuckDuckGo.

6. Simpler Custom Validation Rules

Laravel 5.5 has refined and simplified the creation of custom validation rule with a new artisan command, $ php artisan make:rule FooBarRule. This command creates a new FooBarRule class in the ./app/Rules directory and extends a Rule contract which compels it to apply the passes and message methods. This gives the scope to define the validator logic and error message.

7. New Exception Helper Functions

Laravel 5.5 allows you to write more expressive code with its two exception helper functions: throw_if and throw_unless methods. Both helpers work exactly as their name suggests and may help us to reduce a conditional block to a single line when you want to throw an exception based on a condition.

throw_if throws the exception if the boolean is positive.
throw_unless throws the exception when the boolean is negative.

Both helpers take three arguments, with the third being optional. First one is a boolean, second is the exception class and third is the exception message passed in case you didn’t pass with the instantiation of the exception in the second argument.

8. Supports Customised Email Layouts & Themes

Laravel 5.5 allows you to use custom email themes for mailables. You simply need to create a custom .css file that specifies the style requirement. This simple feature lets you tweak the email layout to your requirements and can be very impactful with respect to branding.

9. Renders Mailables to the Browser

Laravel 5.5 allows you to directly render email layouts to the browser giving you the tool to make instant changes. It displays email templates directly from our routes thus making testing of email templates quicker and easier.

To create a mailable, use
php artisan make:mail UserWelcome–markdown=emails.user.subscription.canceled
And then render it through a route
Route::get(‘/no/way’, function () {
return new App\Mail\UserSubscriptionCanceled();

10. The vendor:publish Command Is More Specific

In Laravel 5.5, when you run a php artisan vendor:publish command, you will be prompted to choose a tag or provider, making it easier to publish only what you want. You can choose to bypass this feature by using the –all or –provider flag

As a leading PHP development company, Carmatec stays on top of all technological advances and applies them to deliver creative solutions for business challenges and requirements. Get in touch with us today to boost your company’s online presence.