Benjamin Crozat The web developer life

Laravel 10: release date and new features

Benjamin Crozat Benjamin Crozat4 minutes read

Before you start reading this article, did you know 76 persons subscribed to my newsletter?

Join them and enjoy free content about the art of crafting websites!

Laravel 10: release date and new features
Table of contents

When will Laravel 10 be released?

Laravel 10 is scheduled to be released in February 7, 2023.

How to install Laravel 10?

Installing Laravel 10 is easy. The Laravel installer has a --dev flag, which installs the master branch from the laravel/laravel repository.

laravel new hello-world --dev

Or, if you prefer to explicitly use Composer:

composer create-project --prefer-dist laravel/laravel laravel-dev dev-master

New features and changes in Laravel 10

Dropped support for PHP 8.0

Some people are barely adopting PHP 8.0. Meanwhile, Laravel 10 will drop support for PHP 8.0, and that’s good.

Remember: big enterprise apps don’t need to be updated to the latest and greatest as soon as they’re released. Enterprise apps have paid clients or employees depending on them to do their work. They need to slowly but surely move forward by doing extensive testing.

See the pull request on GitHub: [10.x] Drop PHP 8.0

Dropped support for Predis v1

If you’re forcing the usage of Predis v1 in your project, you might want to upgrade to v2.

To see what changed in Predis v2, take a look at the changelog.

See the pull request on GitHub: [10.x] Drop Predis v1 support

In my opinion, instead of using Predis, you should consider using PHP’s native Redis extension, which is faster and could speed up your website if you have a lot of traffic.

dispatchNow() has been 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 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 on GitHub: [10.x] Remove deprecated dispatchNow functionality

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. It also means you should carefully test any Laravel application you might want to migrate to version 10.

Here’s a list of all PRs taking care of that:

Laravel 10 uses invokable validation rules by default

In Laravel 9, invokable validation rules could be generated using the --invokable flag with the php artisan make:rule command. Starting from Laravel 10, you won’t need it anymore.

php artisan make:rule Uppercase

To remind you a bit of what invokable validation rules are, here’s what they look like:

namespace AppRules;
 
use IlluminateContractsValidationInvokableRule;
 
class Uppercase implements InvokableRule
{
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param Closure(string): IlluminateTranslationPotentiallyTranslatedString $fail
* @return void
*/
public function __invoke($attribute, $value, $fail)
{
if (strtoupper($value) !== $value) {
$fail('The :attribute must be uppercase.');
}
}
}

The boilerplate code is considerably smaller and easier to understand. Thanks to Laravel 10, people will be less intimidated by the perspective of making custom validation rules.

See the pull request on GitHub: [10.x] Make invokable rules default

The Laravel 10 skeleton uses native types instead of docblocks

Starting with Laravel 10, the skeleton will now use native types instead of docblocks. This PR is massive and is still a work in progress, because it will happen in the whole Laravel organization.

For instance, 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

The team will also add generic type annotations, which will drastically improve autocompletion as well when coding (given your code editor supports generics).

See the pull request on GitHub: [10.x] Uses PHP Native Type Declarations 🐘


This is what’s new in Laravel 10 for now.

There’s more to come until February 2023, though.

Don’t miss any update on this post. Subscribe to my newsletter and follow me on Twitter!

Other posts to read

Debugging requires dissecting everything. Here's a list of all the one-line of code built-in ways to print arrays in PHP.

There are multiple ways to check if an array is empty. Let me tell you about each of them and why and when you should use them.

Learn why the "Invalid argument supplied for foreach()" warning happens, and let me show you multiple ways to fix it.

Let's review some quick wins that Laravel Collections provide to instantly make your codebase better.

Knowing which Laravel version you are running is important before you start writing code on a new project. There are multiple ways to do so.

To keep getting better with PHP, you should subscribe to as many quality blogs as possible. In this article, I share the ones I often read myself.

Here are the best GDPR-compliant Google Analytics alternatives to help you avoid the GDPR penalty and keep your users safe.

Here's a case study for my blog in the programming niche, where I share everything I did to increase clicks by a huge amount since the beginning.

Learn why and how to fix "Methods with the same name as their class will not be constructors in a future version of PHP" warnings.

Are you looking for the best web hosting for Laravel projects and all budgets? I've got you covered. Here are the best I found.