What are the new release features in Laravel 5.6?

Laravel 5.6 was release with new features on 7th February, 2018. Laravel 5.6 is next major version of PHP Laravel web application framework. So, let’s check it out what are the new release features in Laravel 5.6?

 

Added Queueable, SerializesModels to all notification events.

Allow callable array syntax in route definition.

Added JSON SELECT queries to SQL Server.

Logging Improvements

          The biggest feature of Laravel 5.6 is Logging Improvements. In Laravel 5.6 logging configuration moves from the config/app.php file to the new config/logging.php file. By default, Laravel will use the stack channel when logging messages. The stack channel is used to aggregate multiple log channels into a single channel.

Here is the example to define stack channel log.


'stack' => [
       'driver' => 'stack',
       'name' => 'channel-name',
       'channels' => ['single', 'slack']
    ]

Available Channel Drivers are

Stack – A wrapper to facilitate creating “multi-channel” channels
Single – A single file or path based logger channel (StreamHandler)
Daily – A RotatingFileHandler based Monolog driver which rotates daily
Slack – A SlackWebhookHandler based Monolog driver
Syslog – A SyslogHandler based Monolog driver
Errorlog – A ErrorLogHandler based Monolog driver
Monolog – A Monolog factory driver that may use any supported Monolog handler
Custom – A driver that calls a specified factory to create a channel

Dynamic Rate Limiting

Laravel 5.6 introduces dynamic rate limiting that gives you more flexibility and makes it possible to easily rate limit on a per-user basis:


Route::middleware('auth:api', 'throttle:rate_limit,1')

Route::middleware('auth:api', 'throttle:rate_limit,1')
      ->group(function () {
            Route::get('/user', function () {
                //
            });
       });

API Controller Generation

You can now generate a resource controller for APIs that will exclude the unnecessary create and edit actions, which only apply to resource controllers returning HTML. To generate a resource controller, use the –api flag:


      php artisan make:controller API/UserController --api

Single Server Task Scheduling

If you have a task scheduler running on multiple servers, the task will run on each server. You can indicate that a task should only run on one of those servers with the onOneServer() method:


$schedule->command('report:generate')
      ->mondays()
      ->at('05:00')
      ->onOneServer();

Eloquent Date Casting

You can individually customize the format of Eloquent date and datetime casting:


protected $casts = [
      'birthday' => 'date:Y-m-d',
      'joined_at' => 'datetime:Y-m-d H:00'
];

This format is used on model serialization to an array or JSON data.

Blade Component Aliases

You can now alias blade components for more convenient access. For example, if you store a component at resources/views/components/alert.blade.php you can use the component() method to alias it to a shorter name:


       Blade::component('components.alert', 'alert');

You can then render it with the defined alias:


@component('alert')
     <p>This is an alert component</p>
@endcomponent

Argon2 Password Hashing

Laravel 5.6 supports a new password hashing algorithm for PHP 7.2+. You can control which hashing driver is used by default in the new config/hashing.php configuration file.

UUID Methods

Two new methods are now available in the Illuminate\Support\Str class for generating Universal Unique Identifiers (UUID):


return (string) Str::uuid();
return (string) Str::orderedUuid();

 

The orderedUuid() method will generate a timestamp first UUID for easier and more efficient database indexing.

Bootstrap 4

All of the frontend scaffolding and example Vue component now use Bootstrap 4. We have covered Bootstrap 4 while in beta, and even created a Bootstrap 4 Laravel preset. It’s great to see Bootstrap 4 stable shipping with Laravel 5.6!

This release has many new features, and  highlighted the more prominent features over here. For a full list of all changes visit the changelog (GitHub).

 

Post comments for your query!

Leave a Reply

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