What are the new features in laravel 10?
Laravel 10 is scheduled to be released on February 7, 2023. Although its development is still ongoing, we already know about some of the new features that will be included. Let’s take a look at each one.
When will Laravel 10 be released?
Laravel 10 is scheduled to be released on February 7, 2023. However, this doesn’t mean that you have to update all of your projects right away.
The framework last had LTS (Long-Term Support) in version 6, but each major version has two years of updates. This should give you enough time to get your codebase in check and upgrade it before Laravel 10 is no longer supported.
Laravel 9 will receive bug fixes until August 23, 2023, and security fixes until February 6, 2024.
Laravel Version | Supported PHP | Release Date | Bug Fixes until | Security fixes until |
---|---|---|---|---|
8 | 7.3 – 8.1 | September 8th, 2020 | January 24th, 2023 | |
9 | 8.0 – 8.1 | February 8th, 2022 | August 8, 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 3rd, 2026 |
Dropped support for PHP 8.0
There are two things you need to do if you want to upgrade your Laravel project to the latest version:
Either move to PHP 8.1 Or PHP 8.2
But remember: it’s not necessary to update your Laravel apps to the newest version as soon as they’re released.
Especially if you have projects with paid clients or employees who depend on them to do their work.
It’s best to take your time and move forward slowly but surely, doing extensive testing along the way. Don’t rush things.
Invokable Validation rules are the default
Starting in Laravel 10, invokable validation rules are now the default. When you create a new validation rule via artisan, this is what you can expect:
# Laravel 9 creates a rule class that implements the
# Illuminate\Contracts\Validation\Rule interface
artisan make:rule Uppercase
# Laravel 9 flag to create an invokable and implicit rule
artisan make:rule Uppercase --invokable
artisan make:rule Uppercase --invokable --implicit
# Laravel 10 creates an invokable rule by default
artisan make:rule Uppercase
# Laravel 10 implicit rule
artisan make:rule Uppercase --implicit
dispatchNow() is now officially removed
dispatchNow() is a popular method in Laravel. It was deprecated in Laravel 9 in favor of dispatchSync(). Laravel 10 will remove it, so be sure to search for and replace it in all of your projects. It may be a breaking change, but it’s an extremely easy fix.
See the pull request here: [10.x] Remove deprecated dispatchNow functionality #42591
Many deprecated methods and properties have been removed
Releasing a major version also means the Laravel team can finally remove features that have been deprecated in Laravel 9. This also suggests that you should carefully test any Laravel application you might want to migrate to version 10, in order to avoid any compatibility issues.
Here’s a list of all PRs taking care of that:
- [10.x] Remove deprecated Route::home method
- [10.x] Remove deprecated assertTimesSent
- [10.x] Remove deprecated method
- [10.x] Remove deprecated dates property
- [10.x] Use native php 8.1 array_is_list function
- [10.x] Remove deprecations
The Laravel 10 skeleton uses native types instead of docblocks
Starting with Laravel 10, the skeleton will now use DocBlocks instead of native types. This Pull Request is a massive undertaking and is still a work in progress because it needs to be completed for the whole Laravel organization.
For example, in the Laravel skeleton, the schedule() method in app/Console/Kernel.php will look like this:
/**
* Define the application's command schedule.
- *
- * @param IlluminateConsoleSchedulingSchedule $schedule
- * @return void
*/
- protected function schedule($schedule)
+ protected function schedule(Schedule $schedule): void
Migrate your Laravel project easily, let’s connect