iklan

✔ Laravel 5.7 Is Now Released! What's New In Laravel 5.7

Laravel 5.7 is now released and available to everyone. This release introduces several new features and many bug fixes and improvements over Laravel 5.6. Some of the new features include:

Laravel 5.7 Resources Directory Changes

Taylor Otwell announced that in Laravel 5.7 the resources directory will be flattened instead of having an assets folder:

Laravel 5.6’s resources directory looks like this:

resources
├── assets
│   ├── js
│   └── sass
├── lang
│   └── en
└── views

And the upcoming resources directory will look like the following in Laravel 5.7:

resources
├── js
├── lang
├── sass
└── views

Laravel 5.7 Callable Action URLs

A new callable-like syntax for action URLs is coming to Laravel 5.7 thanks to Sebastian De Deyne! You might also hear this feature called “tuple notation” or a “callable array syntax” for URL generation actions.

Here’s how it works starting in 5.7:
$url = action([PostsController::class, 'index']); 

Currently (as of Laravel 5.6) the action helper only supports the following style that you’re probably already familiar with:
$url = action('UserController@profile', ['id' => 1]); 

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

You can find it in the upcoming documentation for URL Generation, and if you’re interested in the code changes made to support this feature, you can check out the 5.7 Tuple notation for UrlGenerator actions pull request.

Laravel Dump Server to Ship With Laravel 5.7

At Laracon US 2018 Taylor Otwell announced that Laravel Dump Server would come packaged with Laravel in version 5.7! It will be a development dependency in laravel/laravel composer file.

Starting in Laravel 5.7 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 Improved Error Messages for Dynamic Calls

Laravel 5.7 makes it easier than ever to track down error messages caused by dynamic calls to Eloquent models (and other parts of the framework) thanks to Bouncer developer Joseph Silber!

You’ll get a more clear picture of the error caused by a missing method instead of a possibly confusing error on the underlying object:

Laravel 5.7: New Pagination Link Customizations

Laravel 5.7 has a new pagination method to customize the number of links on each side of the paginator. Thanks to the new method you no longer need a custom pagination view in some cases. Here’s the API you can use to define the link count on each side of the current page:
User::paginate(10)->onEachSide(5);

Laravel 5.7 Guest User Gates

In Laravel 5.6 and below authorization gates and policies automatically return false for unauthenticated users. New in Laravel 5.7, you can now allow guests to go through authorization checks by using a nullable type-hint or setting the default value as null:
Gate::define('view-post', function (?User $user) {     // Guests  }); 

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

If you don’t use a nullable type hint, guests will automatically get this beautiful 403 response for Laravel 5.7, designed by Steve Schoger (@steveschoger):


Follow our social media and see you next lessons ..

Sumber http://scqq.blogspot.com

Berlangganan update artikel terbaru via email:

0 Response to "✔ Laravel 5.7 Is Now Released! What's New In Laravel 5.7"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel