According to the Semantic Versioning technique, which is used by Laravel and its first-party packages, the framework's main updates are released once a year in the first quarter. Minor changes may, however, be made available as required. The newest iteration of the framework, Laravel 10, is arrived and boasts exciting new features and changes. It will be available on February 13, 2023. Every six months, a new Laravel version was previously published. The core team switched to an annual release cycle, as shown below, but, following the release of Laravel 9 in February 2022:
๐ Laravel 9: February 8, 2022,
๐ Laravel 10: February 13, 2023,
๐ Laravel 11: February 6, 2024
Laravel 9 will receive scheduled bug patches through August 8, 2023, and security fixes through February 6, 2024, according to the official Laravel News Page. Up until August 6, 2024, and up until February 4, 2025, respectively, Laravel 10 is anticipated to receive bug fixes and security updates.
It is advised to use version limitations like "10.0" when referring to the framework or its components in an application or package because the core team behind it is constantly striving to improve what is available to users. This is due to the possibility that later versions will have notable additions and modifications. There are numerous significant enhancements in the most recent version of Laravel 10, which will help product owners. Let's examine these modifications more closely:
Laravel is well known due to its lightweight, built-in templates that are used to create attractive layouts with dynamic content seeding. Laravel offers a large selection of widgets that combine JS and CSS. The templates were ingeniously designed to generate composite layouts that are straightforward for developers to work with.
With the most recent Laravel 10 version, the CLI (Command Line Interface) named Artisan has grown more interactive. With the new Artisan, you may pass the name even if you forget after building a model.
php artisan make: model
If Artisan is unable to retrieve a model name, it won't display any errors. As opposed to that, it will ask you what it is called and whether you want to construct a factory, migrate, etc.
An object that can be referred to as a function in PHP is an "invokable" object. This can be done by calling the magic method __to invoke in the object class definition.
Laravel 9 was offering invokable validation rules using --an invokable flag with php artisan make: rule command.
When an object is used in a situation where a function call is anticipated, such as using () operator, the __invoke method is immediately enabled. When a function is called on an object that has a __invoke method, PHP will automatically run the code inside of that method.
php artisan make: rule LowerCase
Let's see what invokable validation rules look like:
namespace App\Rules;
use Illuminate\Contracts\Validation\InvokableRule;
class Uppercase implements InvokableRule
{
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param Closure(string): Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
*/
public function __invoke($attribute, $value, $fail)
{
if (strtolower($value) !== $value) {
$fail('The :attribute must be lowercase.');
}
}
}
The boilerplate code is far shorter and easier to read. Laravel 10 will make people less afraid of the idea of developing unique validation rules.
Check out the pull request here on GitHub: [10. x] Default to invokable rules
PHP 8.0 is no longer supported by Laravel 10, so you should upgrade to PHP 8.1 or 8.2. But it's not required to upgrade your Laravel applications right away after they're released to the most recent version of Laravel. However, extensive testing is still advised, especially for tasks involving paid customers or workers. In addition, Predis v1 support has been phased down along with PHP 8.0, thus you must upgrade to Predis v2.
The Laravel Pennant is an easy-to-use and compact feature flag package that makes adding new features to your application simple. It supports trunk-based development techniques, has an A/B test interface design, and more. The feature flags enable the at-runtime feature on/off without modifying the code.
You can quickly execute external processes in your Laravel application thanks to the clear and comprehensive Symphony Process API that Laravel provides. With this process functionality, frequent use cases are addressed, greatly enhancing the development experience.
When generating a new Invokable rule with Laravel 9, the -invokable flag had to be included after the artisan command. To create a new Invokable rule, however, you may simply issue the following command in Laravel 10:
php artisan make: rule CustomRule
Furthermore, because the boilerplate code is clear and simple to understand, it is less frightening for developers to write their unique validation criteria.
Formerly, Laravel used DocBlocks in its skeleton code to explicitly describe the purpose of a specific code and the results or parameters it returns. However, all user scripts within the framework now provide type-hints and return types thanks to the most recent Type Declarations. These improvements provide extra advantages and don't affect the backward compatibility of the main framework. Included in this are Method Arguments, Return Types, the removal of superfluous Annotations when practical, the exclusion of the Types property, and the availability of Closure Arguments to Users.
The 'dispatchNow()' method, which was deprecated in Laravel 9 in favor of 'dispatchSync(),' has been removed in Laravel 10. As it is a breaking change, you must replace it in all of your current projects. Fortunately, the fix is straightforward.
With the most recent Laravel version, the team is gradually removing outdated methods from the Laravel 10 branch that existed in Laravel 9. A list of all deprecated methods and packages, as well as an update to the Laravel documentation on the upgrade procedure, can be found there. To get the desired result, those who intend to convert their applications to Laravel v10 will need to rebuild their code using a new methodology. Deprecations and deletions from version 9 to the master branch include the following:
It's crucial to keep in mind that we don't always have to update the Laravel version of our application to the most recent version as soon as a new version is available.
As Laravel is an open-source framework, we automatically become the owners of the framework's codebase each time we install a new Laravel instance on our computer. This implies that our app will continue to function even if the framework version it uses is no longer maintained; we will merely need to maintain it ourselves.
As a result, it is widely suggested that application stability be prioritized over framework upgrades.
In short, you should consider upgrading to Laravel 10 when:
Laravel 10.x Shift makes it simple to upgrade your existing Laravel application to the new version following the official release of Laravel v10. By automating the upgrade from Laravel 9 to Laravel 10, this tool can help you save up to two hours of productive time. It's crucial to remember that Laravel and Laravel 10.x Shift will both get frequent upgrades, and Shift users can ask for a rerun if necessary.
To upgrade your current Laravel application to Laravel 10, a few essential requirements must be met:
The Shift automates many of the upgrades outlined in the Laravel Upgrade Guide, including-
Along with the core upgrades, the Shift also provides additional upgrades mentioned in the Laravel Upgrade Guide, such as:
While the Laravel 10.x Shift strives to automate as many upgrades as feasible, but it's conceivable that some updates cannot be done so. When this happens, it notices the updates and gives thorough guidance in the form of pull request comments that outline the necessary steps for manual implementation.
Despite the Shift's best efforts, a manual implementation may still be necessary to identify and manage upgrades for common dependencies. To guarantee a successful upgrade, it is advised to check the changelog for dependencies and any extra changes.