Laravel 8: O que os desenvolvedores devem saber

Laravel 8: What Developers Should Know

The latest version of Laravel offers a wide range of new features, including a new scaffolding feature and many improvements.

Imagem em destaque

Portable virtual development environment

Laravel 8 New Features

The most recent release of the Laravel framework is Laravel 8. Originally released in late 2020, developers have had a little time to play around with the new version and decide if this release was worth the wait.

New features in Laravel 8 include:

1. Laravel Jetstream

Jetstream comes “out of the box” with many useful features such as login, registration, email verification, session tracking, two-factor authentication, and team management. When it comes to scaffolding, Jetstream offers 2 options: Inertia and Livewire.
Livewire saves developers from having to use a JavaScript framework (like Vue.js) by offering a responsive and dynamic library. Using the Blade templating language, Livewire also offers developers the choice between leaving Blade and using Vue.js if they wish. Inertia uses Vue.js as its template language and offers the full power of the framework without the need for client-side routing.

2. Template factory classes and templates directory

With the release of Laravel 8, eloquent model factories are now class-based. This helps to better support inter-factory relationships.

With this, developers have the ability to manage object states using simple methods, typically by calling the state method (provided in Laravel's factory base class). This takes one argument as a function while taking an array of attributes assigned to the factory.
The Laravel 8 application skeleton includes an Application/Templates directory as well. Although all generator commands assume that the models exist, if the directory in question does not actually exist, the framework assumes that the application keeps the models within the application/ folder.

3. Removed namespace prefix from controllers

In previous versions of Laravel, developers had the ability to use a property called $namespace to automatically prefix the controller namespace by applying Application/Http/Controllers . Previously, Laravel sometimes doubled namespace prefixes when using callable syntax in the web.php route code.

4. Migration crush

For applications that contain many different migration files, developers now have the ability to “zip” them into a single SQL file. When running migrations, this file is run first, followed by any remaining migration files that are not part of the compressed schema file. Squashing migration files like this helps reduce migration file clutter while improving test performance.

5. Job batch

This new version of Laravel also comes with a useful feature that allows developers to dispatch a group of jobs that run in parallel with each other.
Developers can also monitor the progress of batched or grouped jobs by using the then , catch , and finally methods to set their completion callbacks. All callback methods have access to the $batch object, which contains methods such as failure determination, batch cancellation, status checking, and more.

6. Maintenance Mode

In Laravel 7, the framework presented a “whitelist” of IP addresses approved for use in accessing the application during maintenance mode. To simplify things, Laravel 8 now utilizes the “secret” solution where developers have the ability to specify the bypass token using the secret option.

While in maintenance mode, developers can access their application URLs while Laravel automatically passes the bypass cookie to the browser. After issuing the cookie, developers access the application as they normally would in maintenance-free mode.
To prevent users from accidentally using PHP Crafter during deployment, Laravel 8 also provides the option to render a view in maintenance mode and return whenever a request is made.

7. Enhanced Rate Limiting

This latest version of Laravel improves on the existing rate limiting functionality and even supports backward compatibility with existing acceleration middleware. This gives developers much more flexibility than was previously possible.

Laravel 8: going forward

These are just a few of the cool and useful new features released in Laravel 8. Between improved features for developer ease of use, more useful migration and batch processing, as well as the new scaffolding feature, chances are this framework will only continue are among the most used.

Source: BairesDev

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.