Given the increasing demand for high-quality services and updates in the market, the Laravel core team is committed to continuously improving the framework and making it the preferred choice for business owners. As part of this effort, they have recently launched Laravel 10, the latest addition to their franchise. We are here to provide you with an overview of the latest features and updates included in Laravel 10, which are designed to capture the interest of both developers and business owners and encourage them to upgrade their current Laravel applications. Let’s take a closer look at what’s new in Laravel 10.
Laravel 10 Release Date
Laravel adheres to the Semantic Versioning approach for its framework and first-party packages. This means that major updates to the framework are typically released once a year during the first quarter, while minor updates are released as needed. The latest version of the framework, Laravel 10, was released on February 13, 2023, featuring a range of exciting new features and updates. Previously, a new version of Laravel was released every six months.
As reported by the official Laravel News Page, Laravel 9 will continue to receive regular bug fixes until August 8, 2023, and security fixes until February 6, 2024. On the other hand, Laravel 10 is set to receive bug fixes until August 6, 2024, and security fixes until February 4, 2025.
What’s New in Laravel 10: Latest Features and Updates
The Laravel core team is constantly striving to provide the best possible experience to users of the framework. Therefore, it’s highly recommended to use version constraints such as ‘^10.0’ when referring to the framework or its components in an application or package. This is because new versions of the framework may include significant changes and updates. The latest release, Laravel 10, contains several major improvements that will be advantageous to product owners. Let’s delve into these changes and see what’s new in Laravel 10.
PHP 8.0 Support Dropped
With the release of Laravel 10, PHP 8.0 is no longer supported, and upgrading to either PHP 8.1 or 8.2 is required. While immediate upgrading to the latest version of Laravel is not necessary, thorough testing is recommended, particularly for projects with paid clients or employees. In addition to the discontinuation of support for PHP 8.0, support for Predis v1 has also been dropped, and upgrading to Predis v2 is mandatory.
Introduced Laravel Pennant
Laravel Pennant is a lightweight and user-friendly feature flag package that simplifies the process of rolling out new features within your application. It features an A/B test interface design, supports trunk-based development strategies, and provides additional benefits. Feature flags enable you to turn on or off specific features at runtime, without having to modify the code.
Easy Process Handling
Laravel provides a comprehensive API for the Symphony Process component, making it simple to execute external processes in your Laravel application. This feature simplifies the process and enhances the overall development experience, addressing common use cases.
Invokable Validation Rules by Default
In Laravel 9, it was necessary to include the “–invokable” flag when running an artisan command to create a new Invokable rule.
“php artisan make:rule CustomRule”
However, Laravel 10 has simplified the process, and now you can create a new Invokable rule by running a simple command. This improvement is accompanied by a straightforward and easy-to-understand boilerplate code, which makes it less daunting for developers to create their custom validation rules.
Application Skeleton Code with Type Declarations
The latest version of Laravel, Laravel 10, comes with an update to the application skeleton code that replaces DocBlocks with Type Declarations. Type-hints and return types are now featured in all user codes, which provide additional benefits without affecting the backward compatibility of the core framework. The update includes method arguments, return types, elimination of unnecessary annotations when possible, exclusion of types property, and the ability to access closure arguments. These changes make the code easier to read and understand.
The ‘dispatchNow()’ method has been eliminated in Laravel 10, after it was deprecated in Laravel 9, in favor of ‘dispatchSync()’. This change is significant and could cause problems in your existing projects, so it is crucial to replace the old method with the new one. However, this can be easily resolved with a simple solution.
Deprecations from Laravel 9
Laravel 10 has removed several methods that were deprecated in Laravel 9. The Laravel team has updated the documentation to provide guidance on the upgrade process and to include a list of all deprecated methods and packages. To upgrade to Laravel 10, developers will need to rework their code with alternative methods to achieve the same results. The deprecated and removed methods and packages from Laravel 9 to the master branch are outlined in the updated documentation.
- The Route::home method
- The getBaseQuery method, which now has a toBase equivalent
- The MaintenanceModeException class
- The MocksApplicationServices trait
- The Mail::failures method in the mail fake
- A recommendation to use $casts instead of the deprecated $dates property
- The assertTimesSent() method
- Support for Predis 1 and doctrine/dbal 2 are no longer available
- All related deprecations in doctrine/dbal since Laravel has dropped support for version 2
How to Upgrade from Laravel 9 to Laravel 10
If you want to upgrade your Laravel application from version 9 to the latest version 10, you can easily do so with the help of Laravel 10.x Shift. This tool automates the upgrade process and can save you up to 2 hours of time. It’s worth noting that both Laravel and Laravel 10.x Shift receives regular updates, and if necessary, users can request a rerun of the tool.
To upgrade to Laravel 10, there are some necessary requirements.
- First, your Laravel application must be on Laravel 9 or a later version.
- Secondly, your server must have PHP 8.1 or a higher version installed.
The Laravel Upgrade Guide outlines several core upgrades necessary to upgrade your Laravel application to Laravel 10, which are automated by Shift. These include:
- Upgrading core project files,
- Implementing new methods for interface changes,
- Adding PHP-type hints
- Converting the deprecated $dates property to $casts
- Updating core dependencies to support Laravel 10 and PHP 8.1
- Removing redundant typing within PHP DocBlocks,
- Detecting deprecated code within the application code.
Although the Laravel 10.x Shift tool automates most of the upgrade process from Laravel 9 to Laravel 10, there might be some updates that require manual intervention. The tool detects such updates and provides step-by-step instructions in the form of comments within the pull request. It’s essential to follow these instructions to complete the upgrade successfully.
Even though the Shift tool aims to automate upgrades for popular dependencies, manual updates may still be necessary. To ensure a successful upgrade, it’s recommended to review the changelog for dependencies and any other changes carefully.
This wraps up our discussion on the latest version of Laravel, version 10, highlighting its features, updates, and prerequisites. We hope this blog post has provided you with valuable insights into the newest iteration of the framework. However, if you’re hesitant about upgrading your current Laravel application to version 10 or evaluating if Laravel is a suitable solution for your upcoming project, consider hiring a Laravel development company such as Satguru Technologies. Our team of skilled professionals can assist you throughout your web application development process, easing any worries or doubts you may have.