Laravel Version | PHP Version Support | Release Date | Bug Fixes until | Security Fixes until |
---|---|---|---|---|
8 | 7.3 – 8.1 | September 8th, 2020 | July 26th, 2022 | January 24th, 2023 |
9 | 8.0 – 8.1 | February 7th, 2023 | August 8th, 2023 | February 6th, 2024 |
10 | 8.1 | February 7th, 2023 | August 6th, 2024 | February 4th, 2025 |
11 | 8.2 | February 6th, 2024 | August 5th, 2025 | February 4th, 2025 |
As you may know, we’re adding types to user-land code in Laravel 10.x. This applies across the first-party package ecosystem as well, including stubs and starter kits.
To get a head start, we’ve begun releasing some of these changes in packages like Breeze and Jetstream. pic.twitter.com/mqkhL7udhb
— Taylor Otwell (@taylorotwell) January 3, 2023
What’s New in Laravel 10?
Laravel 10, a major Laravel version update, is set to release on the 7th of February, 2023. This update will bring in many new changes, and we have covered some of them below:
Improved Routing Speed and Reliability
Laravel 10 will improve the routing speed and reliability as it has optimized the routing component to minimize the number of method calls and property accesses, reducing overhead and improving speed. Also, in Laravel 10, the handling of nested group routes has been enhanced to reduce complexity and improve reliability.
Route caching implementation has been optimized to reduce overhead and improve performance when generating the route cache. Moreover, automatic namespace model detection has been amended to minimize overhead and give a performance boost when resolving model bindings.
These improvements make Laravel 10’s routing faster and more reliable, providing a better experience for your application’s end users
Built-in Task Scheduling Capabilities in Console Commands
Laravel 10 comes with improved task-scheduling capabilities in console commands. The enhancements include:
- Improved syntax for defining schedule tasks in console commands and the ability to use task schedules in multiple commands.
- Improved support for scheduling tasks in custom intervals.
- Improved task management with the ability to list, inspect, and delete scheduled tasks.
- Improved task execution with better logging and error handling.
These improvements in Laravel 10 make repetitive scheduling tasks in your application easier and ensure they run smoothly.
Laravel Jetstream’s Tailwind CSS-Powered UI Templates
The Laravel Jetstream’s Tailwind CSS-powered UI templates have been improved to provide a more modern and visually appealing interface for your application. The improvements include:
- Better styling and layout options to match your application’s brand and design.
- Improved responsive design support ensures your application looks great on all devices and screen sizes.
- Enhanced navigation options, including the ability to customize the top navigation bar and create custom pages.
- Improved internationalization support allows you to translate your application into different languages easily.
These improvements make it easier to create a modern, visually appealing user interface for your Laravel 10 application, helping to enhance the user experience and make your application more engaging and accessible.
Laravel 10 Skeleton Uses Native Types Instead of Docblocks
Laravel 10 skeleton uses native PHP types for function arguments and returns values instead of relying on PHPDoc blocks for type-hinting. This makes the code more concise and easier to understand and improves performance by reducing the amount of parsing required.
Using native PHP types also facilitates taking advantage of the new type system introduced in PHP 7.4, which provides more accurate type checking and better performance. This change is part of Laravel’s ongoing effort to modernize its codebase and improve the developer experience.
Laravel 10 Uses Invokable Validation Rules by Default
Laravel 10 comes with invokable validation rules that allow you to define validation logic as a single, standalone class. This makes it easier to reuse validation logic across multiple form requests and controllers and helps to keep your code more organized and maintainable.
To use invokable validation rules, define a class that implements the Illuminate\Contracts\Validation\Rule interface, and then use the class name as the validation rule in your form request or controller. Laravel will automatically instantiate the class and execute the validation logic, simplifying your code and improving its readability.
<?php namespace App\Rules; use Illuminate\Contracts\Validation\Rule; class CheckPasswordStrength implements Rule { public function passes($attribute, $value) { // Define your validation logic here. For example: return preg_match('/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9]).*$/', $value); } public function message() { return 'The :attribute must be at least 3 characters long, contain a letter and a number.'; } }
Laravel 10 Drops Support for PHP 8.0
Yes, that’s correct. Laravel 10 has dropped support for PHP 8.0. This means that if you want to use Laravel 10, you must use a more recent version of PHP, such as PHP 8.1 or later.
Dropping support for older versions of PHP is a common practice in the Laravel community, as it allows the framework to take advantage of the latest features and performance improvements in the latest PHP version. Doing so helps the users get a better and more streamlined experience.
So, if you are currently using the PHP 8.0 version and want to use Laravel 10, you will need to upgrade your PHP installation to a more recent version. This may require updates to your code or third-party packages, so it is important to plan ahead and test thoroughly before making any changes to your production environment.
Deprecations & Changes in Laravel 10
In addition to the improved features, Laravel 10 has also introduced some deprecations and changes. The main ones include:
dispatchNow() is Replaced by dispatchSync()
Laravel 10 has replaced the dispatchNow method with dispatchSync. The dispatchSync method works similarly to dispatchNow but provides more control over the job execution process and better performance.
Here’s an example of using the dispatchSync function in Laravel 10:
dispatch(new SendEmailJob($data))->dispatchSync();
The dispatchSync method dispatches a job immediately, bypasses the queue system, and executes the job synchronously within the current process.
The main difference between dispatchSync and dispatchNow is that dispatchSync uses the sync connector instead of the default queue connector.
You can still use dispatchNow by calling the method on an instance of the job you want to dispatch:
dispatch(new SendEmailJob($data))->dispatchNow();
Deprecation of Notification Facade to Notifiable Model Events
In Laravel 10, the Notifications table and the Notification facade have been deprecated in favor of using Notifiable model events. With Notifiable model events, notifications are now sent directly from the model rather than being stored in the database and sent through the Notification facade.
Here’s an example of using Notifiable model events in Laravel 10:
use Illuminate\Notifications\Notifiable; class User extends Model { use Notifiable; public function routeNotificationFor($driver) { if ($driver === 'mail') { return $this->email; } } } $user = User::first(); $user->notify(new UserNotification());
Remove Deprecated Route::home Method
Laravel 10 has also deprecated the Route::home method. In earlier Laravel 10 versions, the Route::home method defined a route that points to the application’s home page.
Here’s an example of how you can define a home route in Laravel 10:
Route::get('/', function () { return view('welcome'); });
Remove Deprecated assertTimesSent
Earlier Laravel version used the assertTimesSent method to check if a certain number of notifications were sent using the Laravel notification system. However, Laravel 10 recommends testing the notifications by using the assertSent method along with the times method.
Here’s an example of how you can use the assertSent method to test notifications in Laravel 10:
Notification::abc(); Notification::send($users, new UserNotification()); Notification::assertSent(UserNotification::class, function ($notification, $channels) use ($users) { return $notification->user->id === $users->first()->id; })->times(count($users));
Use Native PHP 8.1 array_is_list Function
The array_is_list function determines if an array is a list, defined as an array with consecutive integer keys starting from 0. This function can be used in conjunction with other array functions to simplify array operations.
Here’s an example of how you can use the array_is_list function in Laravel 10:
$array = [1, 2, 3, 4]; if (array_is_list($array)) { echo 'This is a list.'; } else { echo 'This is not a list.'; }
By using the latest features in PHP 8.1, Laravel 10 provides developers with a more modern and efficient way to work with arrays in their applications.
How to Get Ready for Laravel 10?
Before updating to Laravel 10, reviewing the release notes and any changes that may affect your application is important. Doing so will help you understand what has changed in the latest Laravel version and plan for any necessary updates to your code. Conduct the following tasks:
Check the PHP version requirement: Laravel 10 requires PHP 8.1 or a later version, so you must ensure you’re using the right PHP version before upgrading to Laravel 10.
Back up your application: Before making any major changes to your application, it’s a good idea to back up your code and database. This will give you a safety net if anything goes wrong during the upgrade process.
Laravel 10 compatibility: Ensure your dependencies, such as third-party packages, are compatible with Laravel 10. You may need to update or replace some of your dependencies to ensure that your application continues to work as expected.
Stop Wasting Time on Servers
Cloudways handle server management for you so you can focus on creating great apps and keeping your clients happy.
How to Contribute to Laravel 10
Laravel encourages its users to contribute to its framework and the development process. But before making any contributions, it’s crucial to have a good understanding of the Laravel framework and how it works.
Create a fork of the Laravel repository on GitHub and clone it to your local machine. This will allow you to make changes to the code, submit them back to the main repository for review, and make changes to the code.
Make sure to follow the Laravel coding standards and contributing guidelines and test your changes to ensure they work as expected and don’t break any existing functionality.
Submit a pull request to the Laravel framework repository, and ask the developers to review and make changes to the platform.
Wrapping Up
Note that Laravel 10 hasn’t been officially released yet. Once Laravel 10 is released and made available on the Cloudways platform, you can upgrade your application to Laravel 10.
With 8% of the market share, Laravel is a smart choice for your PHP framework. We have covered some of the core features expected in the upcoming release. However, we’d only experience Laravel 10 in all its glory on the release date i,e., 7th February 2023.
What are the new features of Laravel 10?
The new features and changes in Laravel 10 are as follows:
- Improved routing speed and reliability
- Built-in task scheduling capabilities in console commands
- Jetstream’s Tailwind CSS-powered UI templates
- Skeleton will use native types instead of docblocks
- Use of invokable validation rules by default
- End of support for PHP 8.0
What is the latest version of Laravel?
Laravel 9 was the last major release that came out in February 2022. Now, Laravel 10 is planned for release on February 7th, 2023.
Is Laravel 10 gonna be an LTS?
Laravel 9 was the first LTS version (Long Term Support), and with its release, the Laravel development team decided to announce updates on a yearly cycle. Laravel 10 will be released on February 7th, with its bug fixes available till 2023 August 6th, and security fixes available till 2024 February 4th, 2025.