“I created an AI assistant for Laravel developers that handles all the boring work.”
Learn more
Smousss
Benjamin Crozat The art of crafting web applications

Laravel 10 is out! Here's every new feature and change.

Benjamin Crozat — Updated on

Laravel is a powerful and flexible PHP web framework that has gained huge popularity in the web development world.

It provides developers with a rich set of tools and features that make it easier to build robust and scalable web applications.

It’s now at its 10th version, and I’ll tell you everything about it.

Table of contents

Laravel 10 is out! Here's every new feature and change.

Laravel 10 release date

Laravel 10 was released on February 14, 2023, and currently is the latest version.

But take it slow! It doesn’t mean you have to update all your projects immediately.

Laravel 9 will receive bug fixes until August 23, 2023 and security fixes until February 6, 2024.

Version PHP Release Bug fixes until Security fixes until
 9 8.0 - 8.1 February 8, 2022 August 8, 2023 February 6, 2024
 10 8.1 - 8.2 February 14, 2023 August 6, 2024 February 4, 2025

Is Laravel 10 LTS (Long Term Support)?

No, Laravel 10 isn’t LTS.

The framework last had LTS in version 6.

That being said, each major version have 2 years of bug and security fixes, which is plenty of time to prepare your application to upgrade to the next major version.

How to install Laravel 10?

Using the official Laravel installer:

laravel new hello-world

Or, if you prefer to use Composer explicitly:

composer create-project --prefer-dist laravel/laravel hello-world

How to upgrade to Laravel v10?

Upgrading to Laravel 10 requires more than just following upgrade instructions. Before proceeding, consider thinking this through.

Check out my guide to upgrading to Laravel 10 if you need more clarification. I also talk about a miracle solution to automatize the process.

What’s new in Laravel 10: features and changes

Laravel Pennant: feature flags with ease

Laravel Pennant

Laravel Pennant is a first-party package that adds feature flags to any Laravel 10 project.

composer require laravel/pennant

Features flags are a way to enable or disable features at runtime without changing your code.

For instance, you can deploy a feature only for a select set of users in your production environment. This is great for A/B testing.

use Laravel\Pennant\Feature;
use Illuminate\Support\Lottery;
 
Feature::define('new-onboarding-flow', function () {
return Lottery::odds(1, 10);
});

Check if the user user has access to the feature:

if (Feature::active('new-onboarding-flow')) {
//
}

There’s even a Blade directive:

@feature('new-onboarding-flow')
@endfeature

Learn more about Laravel Pennant on the official documentation.

Laravel News also has a step-by-step tutorial.

Handle external processes with ease

Laravel offers a simple yet comprehensive API for the Symfony Process component, enabling you to run external processes within your Laravel application easily.

The process functionality in Laravel is designed to cater to the most frequent usage scenarios, resulting in an exceptional experience for developers. 🔥

This is how you use it:

use Illuminate\Support\Facades\Process;
 
$result = Process::run('ls -la');
 
return $result->output();

You can even run processes concurrently. I love the inspiration that comes from Laravel’s HTTP client.

use Illuminate\Process\Pool;
use Illuminate\Support\Facades\Pool;
 
[$first, $second, $third] = Process::concurrently(function (Pool $pool) {
$pool->command('cat first.txt');
$pool->command('cat second.txt');
$pool->command('cat third.txt');
});
 
return $first->output();

There’s more to learn about processes on the official documentation.

See the pull request on GitHub: [10.x] Process DX Layer

Identify slow-running tests

The Artisan command php artisan test can now receive a --profile option that will allow you to easily spot the slowest tests.

I’m glad; this is extremely useful.

This command is provided by the package nunomaduro/collision in its 7th version. Make sure you made the necessary changes if you upgraded from Laravel 9.

Identify slow-running tests in Laravel 10

Laravel v10 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 don’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 App\Rules;
 
use Illuminate\Contracts\Validation\InvokableRule;
 
class Uppercase implements InvokableRule
{
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param Closure(string): Illuminate\Translation\PotentiallyTranslatedString $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.

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 Illuminate\Console\Scheduling\Schedule $schedule
- * @return void
*/
- protected function schedule($schedule)
+ protected function schedule(Schedule $schedule): void

The team also added generic type annotations, which improves autocompletion even further (given your code editor supports generics).

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

Official packages also use native types

Official packages for Laravel won’t be left out of this transition.

Native type hints will be used everywhere across the Laravel organization.

You can check out this PR, that initiates the switch from dockblocks to native type hints in Laravel Jetstream.

https://twitter.com/taylorotwell/status/1610338749065433089

Customize the path of config files

A contributor added the possibility to set a custom path for config files. This is useful for projects slowly migrating to Laravel that can’t handle a radical directory structure change.

In your bootstrap/app.php, use the configPath() method from the $app object.

$app->configPath(__DIR__ . '/../some/path');

(And did you also know about bootstrapPath(), databasePath(), langPath(), etc.? Laravel is highly customizable.)

Learn more: [10.x] Config path customization

doctrine/dbal is not needed anymore to modify columns in migrations

Column modifications happen in your migrations like so:

 
return new class extends Migration
{
public function up()
{
Schema::table('foo', function (Blueprint $table) {
$table->unsignedBigInteger('bar')->change();
});
}
 
}

In Laravel 9, you had to install doctrine/dbal to do the job. But now, migrations support the native operations provided by most of the databases Laravel supports.

Suppose you have multiple database connections and already installed Doctrine DBAL. In that case, you should call Schema::useNativeSchemaOperationsIfPossible() to use native operations before falling back on the package (for instance, SQLite doesn’t support this yet).

use Illuminate\Support\Facades\Schema;
 
 
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Schema::useNativeSchemaOperationsIfPossible();
}
}

Learn more:

Laravel 10 requires at least Composer 2.2

Composer 1.x has been deprecated in 2021.

Therefore, to ensure solid foundations for every new Laravel 10 project, Nuno Maduro proposed to require at least Composer 2.2 (release in December 2021), which also appears to be an LTS version that will be updated until the end of 2023 (Composer is at version 2.5.3 at the time I write these lines).

Learn more: [10.x] Requires Composer ^2.2

Dropped support for PHP 8.0

Laravel 10 dropping support for PHP 8.0 and requiring 8.1 as a minimum means two things if you want to upgrade:

But remember: your Laravel apps don’t need to be updated to the latest and greatest as soon as they’re released.

Especially if you have projects with paid clients or employees who depend on them to do their work.

They need to slowly but surely move forward by doing extensive testing. Don’t rush.

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

PHP 8.1

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:

How to contribute to Laravel 10?

Did you know you could create the next big feature for Laravel 10?

  1. See what’s going on for Laravel 10 on GitHub: https://github.com/laravel/framework/pulls. The Pull Requests will tell you what’s already been done.
  2. Take one of your pain points with the framework and create a solution yourself.
  3. Send the PR over to the laravel/framework repository, collect feedback, improve and get merged.

One important tip to increase your chances of being merged: add something to the framework that’s a win for developers, but not a pain to maintain for Taylor and his team in the long run.

Pull requests on the laravel/framework repository.

Laravel v10 Bug Hunt: win $1K for fixing bugs

Laravel 10 Bug Hunt

Taylor Otwell announced the Laravel 10 bug hunt.

Fix bugs, and be one of the random winner to get $1K richer!

This contest will end as soon as Laravel 10 is released.

Here are the rules:

More details on the official Laravel blog: Laravel 10 Bug Hunt

Recommended

I show you how to upgrade your Laravel 9 project to version 10 and help you decide whether the return on investment is worth it.

I show you how to upgrade your Laravel 8 project to version 9 and help you decide whether the return on investment is worth it.

Learning a framework can be overwhelming, but time and execution will make you a master. Here are some best practices to help you toward your goal.

Laravel 11 will be released on February 6th, 2024. Its development is still ongoing. Let's dive into every relevant new feature we know about already.

Dive into the history of Laravel. If you went away for some time, this is the right place to resume your journey.

Nailing a Laravel job interview can be a daunting task, but with the right preparation and mindset, you can set yourself up for success.

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 about Laravel, the people who use it, and the entrepreneurship spirit that made the framework one of the most profitable open-source projects ever.

Start leveraging the power of AI today. It enables developers to do incredible things, and many startups build products around it.

Store and manage files on Dropbox and use it to back up your Laravel app automatically. Compatible with PHP 8.1+ and Laravel 9+.

Powered by