What's New in Laravel 5.6

The major highlights of Laravel 5.6 :-

API Controller Generation

Laravel 5.6 now offers API controllers that reduces the number of unnecessary create and edit actions that only return HTML. Use the following command to use API controller generation:

php artisan make:controller API/PhotoController --api

Eloquent Date Casting

Laravel 5.6 allows developers to easily change date format as per the project’s requirements.

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

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');

// Once the component has been aliased, you may render it using a directive:

@alert('alert', ['type' => 'danger'])
    You are not allowed to access this resource!

// You may omit the component parameters if it has no additional slots:

    You are not allowed to access this resource!

UUID Methods

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

use Illuminate\Support\Str;

return (string) Str::uuid();

return (string) Str::orderedUuid();

Password Hashing with Argon2

The Laravel Hash facade allows for both Bcrypt and Argon2 hashing for storing passwords. Argon2 is a key derivation function that was selected as the top entry in 2015 Password Hashing Competition

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.

Single Server Task Scheduling

If your application is running on multiple servers, you may now limit a scheduled job to only execute on a single server. If the task scheduler is running on three worker servers, the scheduled task will run on all three servers and generate the report three times. Not good! To indicate that the task should run on only one server, you may use the onOneServer method when defining the scheduled task. The first server to obtain the task will secure an atomic lock on the job to prevent other servers from running the same task on the same Cron cycle:

Note: You must use Memcached or Redis as the default application cache driver to take advantage of single server task scheduling.


Broadcast Channel Classes

If your application is consuming many different channels, your routes/channels.php file could become bulky. So, instead of using Closures to authorize channels, you may now use channel classes. To generate a channel class, use the make:channel Artisan command. This command will place a new channel class in the App/Broadcasting directory.

php artisan make:channel OrderChannel

// Next, register your channel in your routes/channels.php file:

use App\Broadcasting\OrderChannel;

Broadcast::channel('order.{order}', OrderChannel::class);

Logging Improvements

In previous versions, the log location was config/app.php. In Laravel 5.6, logging configuration has been moved to a more logical config/logging.php file.

You configure “stacks” that can send log messages to multiple handlers. For example, you might send all debug messages to a system log and send error logs to slack.

Bootstrap 4

All front-end scaffolding such as the authentication boilerplate and example Vue component have been upgraded to Bootstrap 4. By default, pagination link generation also now defaults to Bootstrap 4.

New Blade Directives

Laravel 5.6 have two new form directives

Cross-site scripting HTTP method input

<form action = "/" method ="post">
<input ...>
laravel series1 - What's New in Laravel 5.52 - What's New in Laravel 5.6

Comments (0)