Laravel has Released its New 5.7 Version: What’s New in it

Laravel is a new free open-source PHP web framework that made its arrival about 7 years ago in June 2011. Since then it has become one of the most popular PHP frameworks for developing web applications. As such, it is based on the MVC (Model View Controller) architectural pattern and Symfony. The first version Laravel 1.0 was released in June 2011 and the 5.6 version came in February this year. And now, the latest variant 5.7 is also on the roll in August 2018. The framework is said to get the bug fixes by February next year and implement the security-based fixes by August 2019.

Laravel framework usually maintains a scheme related to the release of its version. It is based on the following policy which is paradigm.major.minor. It must be noted that the major or key launching is mostly done biannually; i.e. every six months. The releases are announced usually in the month of February and August. On the other hand, the minor or small releases are made almost every week and as such it does not impact any ground-breaking changes.

In every version as we know the development team ties to enhance the improvements from the previous versions and of course, 5.7 are better than its predecessor 5.6. In fact, some new features also have been introduced with this variant. Let’s have crack at some of the important features:

1. Laravel Nova

The Laravel Nova is undoubtedly the most important and significant package or feature that has been introduced by the development team. To tell you more, it is a beautiful administrative panel or dashboard for Laravel development. This admin-panel is driven by a code when a developer commences or is working on an existing a new project. The Laravel 5.6 version also supports the Nova in the form of single composer package. To access more information, you can check out the Nava website.

2. Verifying the Email

It must be noted that with the Laravel 5.7 release, we would also be accessing a new feature, which is known as the email verification. However, if you want to make it count then add the email_verified_at timestamp column to the user’s table migration that is associated with the framework. Apart from that, if you need to suggest the new users to go for the email verification, the User model has to integrate the MustVerifyEmail interface.

<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements MustVerifyEmail
{
// ...
}

Once the incorporation of the interface is complete, the new users will get email that would contain a signed verified link. Upon clicking the link, the application would automatically upgrade the database and redirect the user to a specified location.

In addition, you would also come across another new feature here which is a verified middleware. It helps to secure your application’s routes from verified users and you can attach it with application routes.

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

3. Guest User Gates or Policies

In the earlier version of the Laravel i.e. the 5.6, usually the application access was denied to any unauthorized user as the framework would return false. But as far as the 5.7 variant is concerned, it now offers an optional type hint or provides a default value to allow any user to go through the authentication checks.

Gate::define('update-product', function (?User $user, Product $product) {
         // ...
});

4. Symfony Dump Server

This is another new package that has found its place in the 5.7 version. If we have to define it then, it is actually a command via package that has been developed by Marcel Pociot. The Symfony Dump Server is more than useful in debugging an error in the application for which you don’t have to hinder the application runtime.

The command would run in the background and will gather the data that the application transfers and exhibit in the console mode.

php artisan dump-server
// Output to the HTML file.
php artisan dump-server --format=html > report.html

5. URL Generator & Callable Syntax

This feature has been unveiled with the purpose of controlling the actions by creating the URLs. And Laravel now would support the callable array syntax rather than supporting the strings only. For instance, in the earlier version we had

$url = action('BlogController@index');

$url = action('BlogController@view', ['id' => 1]);

However, presently, it is

use App\Http\Controllers\HomeController;

$url = action([BlogController::class, 'index']);

$url = action([BlogController::class, 'view'], ['id' => 1]);

6. Paginator Links

The Paginator links will now be having three links on each of their sides by default. This allows you to control the number of pagination links that is found on each of the sides of the paginated URLs design. You can control them with the help of this new feature onEachSide (), well supported by Laravel 5.7.


7. Reading or Writing Stream methods in FileSystem

This new feature has been initiated with a view to implement new methods for FileSystem.

Storage::disk('s3')->writeStream(
   'destination-file.zip',
    Storage::disk('local')->readStream('source-file.zip')
);

8. Notification Localization

With the release of this few feature in Laravel 5.7, you will now get the permission to send the notifications in a locale apart from the current languages. In fact, the framework will be familiar with this locale even if the notification is lined up. Even the Illuminate\Notifications\Notification class provides a locale method to get the desired language. When you are formatting the notification, the application gets converted into locale and once this formatting process is complete, it goes back into the previous locale.

$user->notify((new InvoicePaid($invoice))->locale('es'));

If you want to go for localization of various notifiable entries then it is viable to use the Notification façade; such as

Notification::locale('es')
->send($users, new InvoicePaid($invoice));

9. Improvement in the Error Messages

The new Laravel 5.7 offers better scope to detect your errors in your application.

Conclusion

We can see that Laravel in its new version 5.7 has introduced some of the important changes from the previous variants and also brought forward some new features as well. This will certainly make the task of web application much easier.

However, it is advisable that the developers will using the framework and its components should always choose the current version as the minor changes won’t help them much. As far as the paradigm shifting or the changes are concerned, it takes place after a gap of several years when the Laravel team has to introduce a fundamental or architectural change in the framework. At present, there is so such plan of paradigm shifting.


Laravel has Released its New 5.7 Version: What’s New in it posted first on https://thetruthspyblog.blogspot.com

Comments

Popular posts from this blog

Key Insights into Developing an Educational App Helpful for Students and Teachers

Google Released Angular 7: Let’s Get the New Features and Updates

Android P Will Stop Supporting Apps Developed for Android 4.1 or Lower Versions