The latest version of Laravel, which is Laravel 10, has been launched. It comes with several new features, such as the minimum required PHP version being upgraded to v8.1, a new package called Laravel Pennant, invokable validation rules, and the addition of native type declarations, among other updates.
Prior to Laravel 9, major versions of the framework were launched twice a year or approximately every six months. However, the core team changed their approach and moved to an annual schedule, with Laravel 9 being released in February 2022 instead of September 2021 as originally planned. The Laravel framework uses a range of community-driven packages and nine Symfony components to provide various features. With the release of Symfony 6.0 slated for November, the Laravel team opted to delay the Laravel 9 release to 2022 to allow them to upgrade their underlying Symfony components to Symfony 6.0 earlier. This approach will enable them to align their releases with Symfony's and provide users with a better experience. Going forward, the Laravel team will follow a yearly release schedule, with Laravel 10 scheduled for February 14th, 2023, and Laravel 11 slated for Q1 2024. Laravel 9 will continue receiving bug fixes until August 8th, 2023, and security fixes until February 14th, 2024. Laravel 10, on the other hand, will receive bug fixes until August 6th, 2024, and security fixes until February 14th, 2025.
Here are some of the notable new features included in Laravel 10:
Dropped support for PHP 8.0
Laravel 10 will no longer support PHP versions <=v8.0, and the minimum required version is now PHP ^8.1. We can anticipate seeing new 8.1 features being used in the framework, such as readonly properties, based on a comparison between the master and 9.x versions.
Laravel Pennant
Laravel Pennant is a Feature Flag package developed by the Laravel team that will come bundled with Laravel 10. Feature flags enable you to safely roll out new application features, A/B test new interface designs, and implement a trunk-based development strategy, among other things.
This package is the latest addition to the official packages provided by the core team, ensuring that users have access to a well-built and thoroughly tested package that delivers excellent functionality.
Laravel Process Layers
The Laravel Process layer streamlines the testing and running of CLI processes.
Here's an example of how to use it:
use Illuminate\Support\Facades\Process;
$result = Process::run('ls -la');
$result->successful();
$result->failed();
$result->exitCode();
$result->output();
$result->errorOutput();
$result->throw();
$result->throwIf($condition);
The Process layer offers several useful features, such as:
- Fluent methods for constructing a process instance before executing it
- Output handling for processes as they run
- Asynchronous processes
- Process Pools
- Robust testing capabilities via fake()
- Preventing the occurrence of stray processes during testing
Overall, testing processes has never been more straightforward than with the Laravel Process layer.
Native Declaration
Laravel 10's application skeleton code will now have native type declarations, which means that all code generated by the framework in userland will have type hints and return types. However, this implementation comes with certain limitations, which are discussed in the article. Nevertheless, the addition of types will be a welcome feature when starting new projects. The types are added in a manner that incorporates the latest PHP type-hinting features while maintaining backward compatibility at the framework level. Return types and method arguments will now have type declarations, redundant annotations will be removed where possible, and closure arguments can use user-defined types. Typed properties are not included in this implementation.
Invocable Validation Rules
In the latest release of Laravel - version 10 - there's a nifty new feature that will make your life easier when it comes to validation rules. Say goodbye to the hassle of having to implement the Illuminate\Contracts\Validation\Rule interface every time you create a new rule class. With invokable validation rules, it's as simple as creating a new class and adding the __invoke() method. And the best part? Invokable rules are now the default in Laravel 10, so you can save time and effort while keeping your code concise and clean. If you're feeling adventurous, you can even try out the --implicit flag to create implicit invokable rules with ease.
String Password Helper
With Laravel's Str::password method, you can create strong, randomized passwords with ease. The method allows you to specify the length of the password, which can include a mix of letters, numbers, symbols, and spaces. By default, passwords generated by the method are 32 characters long.
Laravel 9 Deprecation
Laravel 10 will remove methods that were marked as deprecated in Laravel 9. To help developers with the upgrade process, the release upgrade guide will provide information on all deprecated methods, their potential impact, and how to upgrade closer to the release.
Here is a list of deprecations that were found when comparing the Laravel framework's master branch to the 9.x branch at the time of writing:
- Various deprecations will be removed in Pull Request #41136
- The deprecated dates property will be removed in Pull Request #42587
- The handleDeprecation method will be removed in Pull Request #42590
- The deprecated assertTimesSent method will be removed in Pull Request #42592
- The $defaultName property of ScheduleListCommand will be removed in commit 419471e
- The deprecated Route::home method will be removed in Pull Request #42614
- The dispatchNow functionality will be removed in Pull Request #42591.
- For example, the assertTimesSent method will be removed in Laravel 10 as it was marked as deprecated in Laravel 9.
0 comments:
Post a Comment