Search

What is new coming to Laravel 9 PHP Framework

  • Share this:
What is new coming to Laravel 9 PHP Framework

Laravel v9, the next LTS version of Laravel, is scheduled to be released in early 2022. In this post, we wanted to go through all of the new features and modifications that have been announced that so far.

 

Changes to the Laravel 9 Release Date

Laravel v9 was supposed to be published in September of this year, but the Laravel Team opted to delay it until January of 2022:

Laravel makes use of a number of community-driven packages as well as nine Symfony components for a range of framework functionalities. Symfony 6.0 is scheduled to be released in November. As a result, we have decided to postpone the release of Laravel 9.0 until January 2022.
By postponing the release, we will be able to upgrade our underlying Symfony components to Symfony 6.0 without having to wait until September 2022. Furthermore, we are better positioned for future releases because our yearly releases will always be two months following Symfony's releases.

This will also cause future major releases to be pushed back, as seen below:

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

 

PHP 8 is the minimum version in Laravel 9

Laravel 9 will require Symfony 6.0, which has a minimum requirement of PHP 8, results show that Laravel 9 would have the same requirement.

 

Routes:list has a new design

The `routes:list` command has been featured in Laravel for a long time, and one issue that occasionally arises is that if you have a large and complicated set of routes specified, it might be difficult to display them in the console. This is being updated as a result of a pull request from Nuno Maduro.

 

Laravel 9 Route List

 

Anonymous Stub Migrations

Laravel 8.37 was released earlier this year with a new feature called Anonymous Migrations, which eliminates migration class name clashes.

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {

    /**
    * Run the migrations.
    *
    * @return void
    */
    public function up()
    {
        Schema::table('people', function (Blueprint $table) {
            $table->string('first_name')->nullable();
        });
    }
};

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


New Query Builder Interface

Laravel 9 will have a new Query Builder Interface, thanks to Chris Morrell, and you can find all the details in this merged PR.

For developers that use type hints in their IDE for static analysis, refactoring, or code completion, the lack of a shared interface or inheritance across them can be frustrating `Query\Builder`, `Eloquent\Builder` and `Eloquent\Relation` can be pretty tricky:

 

return Model::query()
    ->whereNotExists(function($query) {
        // $query is a Query\Builder
    })
    ->whereHas('relation', function($query) {
        // $query is an Eloquent\Builder
    })
    ->with('relation', function($query) {
        // $query is an Eloquent\Relation
    });

This feature adds a new `Illuminate\Contracts\Database\QueryBuilder` interface and an `Illuminate\Database\Eloquent\Concerns\DecoratesQueryBuilder`  trait that replaces the previous `__call` implementation with an interface implementation.

 

PHP 8 String Functions

Tom Schlick filed a PR to switch to PHP 8 because it will be the minimum `str_contains()`, `str_starts_with()` and `str_ends_with()` functions internally in the `\Illuminate\Support\Str` class.


SwiftMailer has been replaced with Symfony Mailer

SwiftMailer has been deprecated by Symfony, and Laravel 9 now uses Symfony Mailer for all mail transports. There are a few breaking changes as a result of this, and you can see the PR for more information. Once Laravel 9 is launched, instructions will be included in the upgrading guide.

 

The server.php file can be removed

It's a little change, but you can now remove the `server.php` file from your project and the framework will still include it. Only `php artisan serve` makes use of this file.


And there's more...

Laravel 9 will be released in a few months, and there will be more new features and announcements. As new events are announced, we will update this post.

 

About author
I am a professional web developer. I love programming and coding, and reading books. I am the founder and CEO of StorialTech.