Whats new in laravel 5.5?

Whats new in laravel 5.5?

Whats new in laravel 5.5?. Laravel 5.5. going to release in July of 2017. Laravel 5.5 have few updates from laravel 5.4. Lets see what are the additions are added in laravel 5.5

Whoops is coming back

Whoops is used to handle the error which was built in with laravel 4 and later it was removed in laravel 5.5. Its come with new advanced features. Now laravel whoops screen will list out all errors, and By clicking the error name you can find out the exact error place mentioned.

Fresh Migration

In previous versions we have artisan command called

It will rollback all migrations and re-migrate it again.

Now laravel 5.5 introduces new artisan command called

It will drop all tables and re-run all migrations. 

Assets preset

Laravel 5.5 have introduced new artisan command called

Which is used to swap the scaffoldings.

In default we have installed with bootstarp, vue in front end assets directory. By using preset command we can swap it.

Under php artisan command we can see new command called preset.

There you can find out how to use preset in artisan command and what are the preset types are available to swap.

Example 1 => It Will strip everything and just will keep basic scaffoldings under front end assets directory.

Example 2 => It Will swap the application to vue, and you can find vue components under resources/assets folder.

Example 3 => It Will swap the application to react, and you can find react components under resources/assets folder.

Example 4 => It Will swap the application to bootstrap, and you can find bootstrap components under resources/assets folder

Automatic package discovery

Till date, Once you install any package, you need to register Service provider and Alias at app.php Instead, Now we can add Service provider and Alias at Package composer.json itself. So while installing package it will detect it automatically and register it.

How to add service provider and alias in composer.json file :

 Note  : You should not do it in your laravel composer.json, It should be added in package.json file.

Test your Email layout in browser

By using below command we can create a mail,

You can see Welcome Mail under mail folder and template at views emails folder.

Now write a route :

and run your route in browser. You can see your email layout at browser. There you can debug it easily

Easy custom validation rules

Run :

You can find new artisan command called make:rule => Which will help you to make a new validation rule.

It will create CheckLessThanFive.php under Rules folder. Under passes() function you can write your own validation rule.

for eg : return $value < 5;

How to use this in your controller validation rule area

Collection Dumping

Normally we will use dump() or dd() to print the data at the end of scope.

for eg :

Now in laravel 5.5 we can dump at any place.

for eg :

It will dump the data in each steps.

Factory Generation

Till date we have a only one Factory under database folder to create a fake users. Like that we can now make a multiple Factories based on Model name

It will create PostFactory.php file under factories folder. The you can fill up your table fields and by running tinker command can create fake posts

Custom Blade “If” Directives

My if condition at blade :

Now we are going to customise if condition :

To make this custom directive possible, you need to write it in your AppServiceProvider.php => boot() function

you can pass param also :