Laravel 5.7 is now available! Let’s see all new features

Laravel has been consistently adding useful features since it’s the 1st release. Now new interesting features are added to Laravel 5.7. The main features new includes Laravel Nova, optional email verification to the authentication scaffolding, support for guest users in authorization gates and policies, Symfony dump-server integration, localizable notifications.

Let’s discuss each feature in details.

1. Laravel Nova

Laravel Nova

Laravel Nova is a Laravel package which is used to make a wonderful admin panel. You can install it in your new project or even in the existing project via composer. Good news is that it even supports for Laravel 5.6. It uses Vuejs, Vue Router, and Tailwind as frontend. As Tailwind.css was recently released which is a utility CSS framework. You can find more about in its official documentation.

Laravel Nova includes from the basic CRUD operations to complex search, filters, lenses, metrics operations. You can read a detailed article by Taylor Otwell on medium or it’s official documentation.

2. Email Verification

Laravel now even has optional email verification to Laravel default authentication system. A new column email_verified_at has been added in the users table. You don’t need to add yourself, it comes with default migration. You just need to run the migration.

The User model should implement the MustVerifyEmail interface to suggest new user to verify their email address. So, your User model looks like below:

After this implementation, newly registered user get an email containing a verification link to activate the account. So, when user clicks on the link, the account is activated.

Laravel 5.7 also provides a middleware which restricts only for verified emails only. So, this can very handy and useful for backend functionality.

To protect your routes only for verified emails, attach the middleware in the routes.

3. Guest User Gates / Policies

Guest User Gates is another useful feature that is included in Laravel 5.7. Until now, Laravel used to return false when visitors try to access unauthenticated routes. But in Laravel 5.7, you can type-hint the model or anything or simply return null to return accordingly.

4. Symfony Dump Server

Have you ever considered of dumping data in the console or to an external HTML file? Then, it’s great that Laravel 5.7 will have a built-in feature for this. You can easily dump your data in the console or even in HTML file.

This command is very useful and a lot useful for debugging purpose without interrupting the application runtime.

You can see it in action here:

You can find more about this package in its Github repository.

5. Notification Localization

In Laravel 5.7, you can send notification other than the current language. For this, you need to specify the language you need to use in notification inside locale method. For example:

Localization of multiple notifiable entries may also be achieved via the Notification facade:

6. Improved Error Messages

Now Laravel 5.7 uses bouncer package developed by Joseph Silber. This will show errors message on dynamic calls and Eloquent models. You can directly get the clear error message without other underlying object messages. Joseph introduced in one of his tweets

7. URL Generator and Callable Syntax

A new callable-like syntax for action URLs is coming to Laravel 5.7. It is the same as the in Laravel 5.6 which accepts a string in action method. This main benefit of this new syntax is that you can directly navigate to the controller from it.

8. Resources Directory Changes

There will be a minor modification in the resources directory. There is nothing new but the assets directory will be removed and js and sass directory will be opt-out to resources directory. Taylor announced in one of his tweets that resources directory will be flattened as below:

When you upgrade the Laravel version, you don’t need to reconstruct the resources/asset directory according to the newer directory structure. It will work with older structure.

9. Paginator Links

This small feature in this new version may be useful in many cases. This feature will help to control how many additional links are displayed on each side of the paginator’s URL “window”.

If you have used paginations before then you might have noticed three links which are by default. But, you can explicitly define in Laravel 5.7.

10. Filesystem Read / Write Streams

Laravel’s Flysystem integration now offers readStream and writeStream methods:

Leave a Reply

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