SurroundBG has new website!
September 9, 2018
Our selection of Top 5 WordPress plugins for basic e-commerce
January 30, 2019

Laravel 5.7 is now available

Laravel 5.7 has been released and is now available for download, adding several new features and further expanding on the improvements added in version 5.6 by introducing Laravel Nova. A number of bugs also appear to have been cleaned up together with the new additions.

This also means that Laravel 5.6 will stop receiving bug fixes with the release of 5.7, although it will keep receiving security updates until January of 2019.

As per Laravel’s support policy, we can expect bug fixes and support for version 5.7 to be maintained until March 4th, 2019, with security updates scheduled to expire on September 4th, 2019.

Laravel Intro

Laravel is a web application framework with expressive, clean and fairly elegant syntax. The creators of it firmly believe that development must be an enjoyable, creative experience which should be truly fulfilling. Laravel attempts to take the pain out of the  development of large projects by easing common tasks used in the majority of web applications, such as authentication, routing, sessions, and caching.

The framework is a set of classes which make a  developer’s  life much easier. A good example is when a developer chooses to hide some complex Hypertext Transfer Protocol(HTTP) or a case of adding essential functions.

Laravel allow you to do more with less code. It is currently the most popular and well-established MVC framework for PHP. Renowned for it’s ease of use and clean, “to the point” design.

Installation

For the purpose of this installation tutorial we are going to assume that you have a Laravel application already installed on your web server. The basic requirement for installing 5.7 is PHP version 7.2

To install version 5.7, simply start your composer and enter the create-project command in your terminal such as:

composer create-project --prefer-dist laravel/laravel application

If Laravel is properly installed, you will see the default starting page as soon as you open your application in any browser.

Laravel Nova

Perhaps the main feature coming to Laravel with version 5.7 is Laravel Nova, an administration dashboard for Laravel applications. Nova offers support for filters, lenses, actions, queued actions, metrics, authorization, custom tools, custom cards, custom fields. The primary feature of the dashboard is, however, without a doubt ability to administer your underlying database records using Eloquent.

Laravel Nova, which is a Composer installed package can also be used as a standalone service. It makes it possible to build an admin dashboard panel.

Purchasing a license for the package comes at a price point of $90 per site for a solo and $199 per site for an enterprise plan. Laravel Nova has several required packages which you will need before you can install and use it:

– Composer

– Node and Npm

– Laravel Framework 5.6+

– Laravel Mix

When the above requirements are met, you may download a Nova release from the release section on the Nova website after purchasing a license.

Email verification

Another notable feature of version 5.7 is email verification. This version provides us with an out of the box solution for verifying user emails, fully configured and ready for use. This can be implemented in Laravel 5.7 by using the Illuminate\Auth\MustVerifyEmail trait on an App\User model.

Furthermore, a table of users which uses email verification must have an email_verified_at. This feature now makes easier to implement email verification on each application people build by using the Laravel framework.

Once the User model is marked with the MustVerifyEmail interface, newly registered users will receive an email containing an already signed verification link. Once this link has been clicked, Laravel will automatically record the verification time in the database and redirect users to a location of your choosing, greatly expediting the process of verification which previously required a custom solution.

Guest User Gates / Policies

The previous version of Laravel used to return “false” if an unauthenticated user attempted to access the application. However, with the new version (5.7) it will now allow declaring an “optional” type-hint or supplying a null default value in order to permit the guest user to pass through the authorization checks which were locked down in previous versions.

By using a nullable type hint the $user variable will be null when a guest user is passed to the gate, and from there you can then make decisions about authorizing the action. If you allow nullable types and return true, then the guest will be granted authorization.

Pagination Link Customizations

Laravel 5.7 also adds  a new pagination method which allows you to to customize the number of links on each side of the paginator. Thanks to the new method you no longer need to create a custom pagination view in some cases.

Here’s the API which can be used to define the link count on each side of the current page:

User::paginate(10)->linksOnEachSide(5);

This new feature will be excellent to cut out the need for a custom template in some cases, but it’s still useful to know how to customize the pagination view.

Testing with Artisan

Laravel 5.7 also makes it possible to test console applications which accept inputs. Testing console applications is fairly simple, just by using the three methods, expectQuestion, expectsOutput, and assertExitCode. An example of the methods can be seen below:

/**
 * Testing console command.
 *
 * @return void
 */
public function console_command()
{
    $this->artisan('code:style')
         ->expectsQuestion('What is your favorite PHP framework?', 'Laravel')
         ->expectsQuestion('Do you build agile web applications with Laravel?', 'Yes')
         ->expectsOutput('Your favorite PHP framework is Laravel and you build agile web applications with Laravel.')
         ->assertExitCode(0);
}

In conclusion:
The agile web development is easier than ever with Laravel 5.7. You can read the full documentation of Laravel here. Get in touch with us here, if you need help with your Laravel project.