Posted: 05-09-2018

Laravel 5.7 is out

Laravel  5.7 is out


Laravel 5.7
has been released and available to download.

This introduces several new features, bug fixes and improvements.
According to the documentation will receive bug fixes and updates until February 2019 and security fixes until August 2019.

Upgrade from version 5.6 seems to be quite easy.

The Estimated Upgrade Time is around 10 - 15 Minutes.

You can find the upgrade guide at the Laravel official upgrade documentation

Hereafter a  short list of the new features.

Improved Error Messages for Dynamic Calls

In @laravelphp 5.7 you'll now get a clear, concise message saying that the method doesn't exist on the mode.

Read more at Laravel news.

Coalesce Operator in Blade template

In Laravel 5.7 the Blade “or” Operator is replaced by PHP 7’s Null Coalesce Operator.

//laravel 5.6
$user or "Guest"
//now in 5.7
$user ?? "Guest"



Pagination view customization

Now You can customize the number of pages to show on each side of the current page without having to extend the pagination view-

$paginator->onEachSide(5)->links()

 

Email Verification

Optional email verification to the authentication scaffolding is added to the framework. To accommodate this feature, an email_verified_at timestamp column has been added to the default users table migration that is included with the framework.

In order to verify their email, the User model should be marked with the MustVerifyEmail interface. 

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
    // ...
}

 

You can use the new verified middleware  in order to protect you routes to only users with verified email

'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class


Add the verified middleware to your route in this way:

Route::get('user/profile', function () {
    //
})->middleware('verified')

 

Laravel Dump Server

Laravel 5.7 offers integration with Symfony's dump-server command via a package by Marcel Pociot.
Now you to dump data to the console or an HTML
To get started, run the dump-server Artisan command:

php artisan dump-server
# Or send the output to an HTML file
php artisan dump-server --format=html > dump.html.

 

Notification Localization

Laravel now allows you to send notifications in a locale other than the current language, and will even remember this locale if the notification is queued.

$order->notify((new InvoicePaid($invoice))->locale('it'));

or using Facades 

Notification::locale('it')->send($users, new UserCreated($user))

 

Resources Directory Changes

As announced by Taylor in a tweet , Laravel 5.7 comes  with some little change in the resources directory.

The assets directory will be removed and js and sass directory will be opt out to resources directory.


A full list of new features is available at Laravel 5.7 Release Notes page.

 

Additional resources about  what's new in 5.7 release/h3>