New features in Laravel 5.6

laravel 5.6 new features

Laravel 5.6 is now officially available. This release has many highlighted features. You can see all the changes in this link. Some of the main features are listed below:

New Blade Directives

In laravel 5.6 you can access blade components in a subdirectory with the help of aliasing. Suppose, we have a new blade components at resources/views/components/alert.blade.php . We can use the component method to alias the component from components.alert to alert:

Now, we can invoke the component like this:

Bootstrap 4

Laravel 5.6 comes with bootstrap 4. All the front-end component including authentication boilerplate, vuejs component, pagination uses Bootstrap 4. It is not necessary to use bootstrap 4, you can also use bootstrap 3 by changing some small changes but it’s good to use bootstrap 4 rather than bootstrap 3.

Logging Improvements

There is now a separate logging configuration file in laravel 5.6 to send logging stacks messages to various handlers. Simple overview of logging file looks as below:

Argon2 Password Hashing

Another new functionality of Laravel 5.6 includes Argon2 Password Hashing Algorithm. You can set the driver setting for hashing in config/hashing.php. However, you php version must be greater than 7.2 in order to use it. According to laravel news, Argon2 comes in the following three versions:
• Argon2d maximizes resistance to GPU cracking attacks.
• Argon2i is optimized to resist side-channel attacks. It accesses the memory array in a password independent order.
• Argon2id is a hybrid version. It follows the Argon2i approach for the first pass over memory and the Argon2d approach for subsequent passes.

API Resource Controller Generation

In the previous laravel version, after controller resource, you have to manually delete with all the unnecessary methods when you are working with API. But, In Laravel 5.6, you can create a controller resource for api that only methods skeleton that are required for API. To use this, you can simply run the below command:

Eloquent Date Casting

With Laravel 5.6, it is easier to format your date and time as required by your project. To do this, you need to specify the desired date format in $cast array in your model.

Single Server Task Scheduling

With Laravel 5.6, we can now limit a scheduled job to only execute on a single server using the onOneServer when defining the task.

Notice: You must use Memcached or Redis as the default application cache driver to do single server task scheduling.

UUID Methods & other Helpers

Laravel 5.6 introduced helper methods, Arr::wrap(), classes_uses_recursive(), Str::uuid(), and Str::orderedUuid().

The orderedUuid method will generate a timestamp-first UUID that is more easily and efficiently indexed by databases such as MySQL.

Dynamic Rate Limiting

Before Laravel 5.6, laravel’s rate limiting need to be specified using hard-coded number of request s. This has changed since laravel 5.6. Now, its pdynamic rate limiting is possible that gives you more flexibility and makes it possible to easily rate limit on a per-user basis.

Broadcast Channel Classes

Instead of using closures like in previous laravel versions that use closures, we can now use Channel Classes. Broadcast Channel Classes can be generated using following command:

After creating channel, we can register it in routes/channel.php file

Artisan optimize removed

Laravel 5.5 documentation states that, “With recent improvements to PHP op-code caching, the optimize Artisan command is no longer needed. You should remove any references to this command from your deployment scripts as it will be removed in a future release of Laravel.” Thus, php artisan optimize has been removed from Laravel 5.6