A look at what is coming to Laravel 9


January 6th, 2022


Laravel v9 will be the next LTS version of Laravel, and it will be coming out sometime in early 2022. In this post, we wanted to outline all the new features and changes announced so far.

Laravel 9 Release Date Changes

Laravel v9 was scheduled to be released around September of this year, but the Laravel Team decided to push this release back to January of 2022:

Laravel uses a variety of community-driven packages as well as nine Symfony components for a number of features within the framework. Symfony 6.0 is due for release in November. For that reason, we are choosing to delay the Laravel 9.0 release until January 2022.
By delaying the release, we can upgrade our underlying Symfony components to Symfony 6.0 without being forced to wait until September 2022 to perform this upgrade. In addition, this better positions us for future releases as our yearly releases will always take place two months after Symfony's releases.

This will also push future major releases back as well, and here is the schedule going forward:

  • Laravel 9: January 2022
  • Laravel 10: January 2023
  • Laravel 11: January 2024

PHP 8 the minimum version in Laravel 9

Since Laravel 9 will require Symfony 6.0 and it has a minimum requirement of PHP 8 that means Laravel 9 will carry this same restriction.

New Design for routes:list

The routes:list command has been included in Laravel for a long time now, and one issue that some times arise is if you have a huge and complex routes defined it can get messy trying to view them in the console. Thanks to a pull request from Nuno Maduro this is getting a makeover.

New Test Coverage Option

A new artisan test --coverage option will display the test coverage directly on the terminal. It also includes a --min option that you can use to indicate the minimum threshold enforcement for test coverage.

Anonymous Stub Migrations

Earlier this year, Laravel 8.37 came out with a new feature called Anonymous Migrations that prevents migration class name collisions.

1use Illuminate\Database\Migrations\Migration;
2use Illuminate\Database\Schema\Blueprint;
3use Illuminate\Support\Facades\Schema;
5return new class extends Migration {
7 /**
8 * Run the migrations.
9 *
10 * @return void
11 */
12 public function up()
13 {
14 Schema::table('people', function (Blueprint $table) {
15 $table->string('first_name')->nullable();
16 });
17 }

When Laravel 9 launches, this will be the default when you run php artisan make:migration

New Query Builder Interface

Thanks to Chris Morrell, Laravel 9 will feature a new Query Builder Interface, and you can see this merged PR for all the details.

For developers who rely on type hints for static analysis, refactoring, or code completion in their IDE, the lack of a shared interface or inheritance between Query\Builder, Eloquent\Builder and Eloquent\Relation can be pretty tricky:

1return Model::query()
2 ->whereNotExists(function($query) {
3 // $query is a Query\Builder
4 })
5 ->whereHas('relation', function($query) {
6 // $query is an Eloquent\Builder
7 })
8 ->with('relation', function($query) {
9 // $query is an Eloquent\Relation
10 });

This feature adds a new Illuminate\Contracts\Database\QueryBuilder interface and a Illuminate\Database\Eloquent\Concerns\DecoratesQueryBuilder trait that implements the interface in place of the existing __call implementation.

PHP 8 String Functions

Since PHP 8 will be the minimum, Tom Schlick submitted a PR to move to using str_contains(), str_starts_with() and str_ends_with() functions internally in the \Illuminate\Support\Str class.

From SwiftMailer to Symfony Mailer

Symfony deprecated SwiftMailer and Laravel 9 makes the change to use Symfony Mailer for all the mail transports. This does open up a few breaking changes and you can review the PR for all the details. The Laravel 9 upgrade guide will include instructions once it's officially released.

The server.php file can be removed

A minor feature but you can now remove the server.php file from your project and it will be included inside the framework. This file is only used for php artisan serve.

And More...

Laravel 9 is still a few months away, and more new features and announcements will be coming out. We will be updating this post as those get announced.

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.