What new features and update Taylor Otwell give for Laravel 5.7

An introduction to some of the new features and updates added to Laravel 5.7 by Taylor Otwell

What's new in Laravel 5.7

  1. Testing Console Commands in Laravel 5.7
  2. Pagination Link Customizations
  3. Improved Error Messages for Dynamic Calls
  4. Laravel Dump Server
  5. Laravel 5.7 Callable Action URLs
  6. Resources Directory Changes
  7. Laravel 5.7 Email Verification


Testing Console Commands in Laravel 5.7

Laravel 5.7 simplify HTTP testing by  providing a simple API for testing console applications that ask for user input. 

Now we can easily "mock" user input for the console commands using expectsQuestion method and also specify the exit code and text that you expect to be output by the console command using the assertExitCode and expectsOutput methods.


Finally all together we have,

expectsQuestion() method asserts that a given question was asked by the Artisan Console.

expectsOutput() allows you to make assertions on the output of your console command.

assertExitCode() helps you make assertions on the output of the console command.


Pagination Link Customizations

Laravel 5.7 has a new pagination method to customize the number of links on each side of the paginator.

Now we no longer need a custom pagination view in some cases. Here is an example showing how you can add the link count on each side of the current page:

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


Improved Error Messages for Dynamic Calls

In Laravel 5.7 you'll get a more clear and concise picture of the error caused by a missing method instead of a possibly confusing error on the underlying object. Laravel 5.7 makes it easier to track down error messages caused by dynamic calls to Eloquent models and other parts of the framework.


Laravel Dump Server

Laravel Dump Server is a package by Marcel Pociot, which brings Symfony's Var-Dump Server to Laravel. Laravel Dump Server is now packaged with Laravel 5.7 which will be the development dependency in laravel/laravel composer file. You'll get this command out-of-the-box that allows you to dump data to the console or an HTML file instead of to the browser.


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


The command runs a server in the background that collects data sent from the application that sends the output through the console. When the command is not running in the foreground, the dump() function works as expected by default.


Laravel 5.7 Callable Action URLs

A new callable-like syntax for action URLs has been implement in Laravel 5.7 by Sebastian De Deyne! You might also hear this feature called tuple notation or a callable array syntax for URL generation actions.

Here is how it works starting in 5.7:

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

If you use a text editor or IDE that supports code navigation, one benefit of the new callable array syntax format is the ability to navigate to directly to the controller.


Resources Directory Changes

Taylor Otwell have flattened the resources directory instead of having an assets folder.


Laravel 5.7 Email Verification

If you want to make your web applications more secure, it requires users to verify their email addresses before using the application. Rather than forcing you to re-implement this on each application, Laravel now provides a convenient methods for sending and verifying email verification requests.


Laravel 5.7 introduced an optional email verification to the authentication scaffolding. You will find a new column email_verified_at in your user table, which will be used to store the date and time that the email address was verified. By default, the users table migration included with the Laravel framework already includes this column. So, all you need to do is run your database migrations.


Note:
To get started, verify that your App\User model implements the  
Illuminate\Contracts\Auth\MustVerifyEmail contract.


After an email address is verified, the user will automatically be redirected to /home. You can customize the post verification redirect location by defining a redirectTo method or property on the VerificationController.




Back to News