Laravel 10: release date and new features

Laravel 10: release date and new features

Laravel 10 will be released on February 7, 2023. Its development is still ongoing. Let's dive into every relevant new feature we know about already.

ยท

4 min read

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

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!

ย