DEV Community

Cover image for Laravel 9.0: An Exhaustive Rundown Of What Is To Be Expected
Faruk Nasir
Faruk Nasir

Posted on

Laravel 9.0: An Exhaustive Rundown Of What Is To Be Expected

The Laravel release cycle was updated to include one major release every year. Due to this change, Laravel 9––the next LTS version of Laravel––was expected to be released in September of 2021.

That didn't happen.

Taylor wrote in the Laravel blog that the Laravel team had decided to postpone the release of Laravel 9 to early 2022––couple of months after the release of Symphony 6.0––as that will allow them to upgrade the underlying Symphony components utilised by Laravel. Otherwise, they'd have to wait until September of 2022 for such upgrade. This means that we should expect the release of L10 in January of 2023.

With L9 release nearly on us, I've decided to put together all that is contained within so far.

PHP8.0: The Minimum Version of PHP For Laravel 9 Applications
Symphony components will be updated to version 6.0 in L9. The minimum supported version of php in Symphony 6.0 is 8.0. So, automatically, the minimum supported version of PHP in L9 will, also, be 8.0.

A Slick Upgrade For php artisan route:list
route:list is that artisan command that allows for quick navigation of all routes in the terminal. But, If you have used it before, you'd agree with me that it's really been short in the navigation aspect, especially, on smaller screens. Routes are, extremely, difficult to spot––and that, single-handedly, defeats it's purpose.

original route list

L9 ships with a smooth upgrade that changes––for the better––how the routes are displayed. The new route:list command can be ran in two modes: default and verbose.

To run in the default, use the same old syntax: php artisan route:list. This will display the routes beautifully in a table of columns: method, domain@uri and action. And, it is designed to be, truly, responsive even in smaller screens. To ensure the responsiveness, actions with long names are truncated.

new route list

The verbose mode is activated by appending -v at the end of the default command. It should look like the following:

php artisan route:list -v
Enter fullscreen mode Exit fullscreen mode

With the verbose mode, in addition to the method, domain@uri and action, two more columns are displayed: name and middleware and no column is truncated. Even the verbose mode is far better than the old display.

No changes in behaviour in all the options(sort, json etc) of the old command except with columns and compact that have been removed entirely.

There is a breaking change introduced with this make-over. Read all about it here .

L8's Anonymous Stub Migration Will Become The Default
The release of Laravel 8.37 came with anonymous migration support.

Imagine––during the course of your application development––you create an add_tags_column_to_post_table migration. In a following version, you decide to remove the tags column with a migration file remove_tags_column_to_post_table. In a future version, due to a change in requirements, you decide to put back the tags column using the migration file add_tags_column_to_post_table.

Notice that the first and third migration files' names are the same.

At this point of the migration history, running it is hardly a walk-in-the-park––as it should be, unless, you are running it––in a newly created database, while running tests or in an application that is well-tested. The most trouble is for large applications with quite a number of years in development that are poorly tested. This is the problem that Anonymous Migrations solves.

In L9, it will replace the old way migration was handled. The feature is backward-compatible. That means, it can be used with previous versions of Laravel.

The following is what an anonymous migration file looks like:

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('posts', function (Blueprint $table) {
            $table->json('tags')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('posts', function (Blueprint $table) {
            $table->dropColumn('tags');
        });
    }
};
Enter fullscreen mode Exit fullscreen mode

Replacement of SwiftMailer by Symphony Mailer
In August of 2019, Fabien Potencier wrote about his decision to replace Swiftmailer with Symphony Mailer in a short blog post. Laravel follows suite in version 9.0.

Here is the PR that made it all happen.

The server.php file in The Root Directory Can Be Safely Removed
The server.php file, usually, found at the root of a Laravel application's folder is only used for the php artisan serve command. In L9, it can be safely removed as the command's implementation will be included inside the framework. Tiny but, gold!

Replacement Of Str Functions' Internal Logic With PHP's methods
PHP 8.0 shipped with 3 new saucy string functions: str_contains, str_starts_with and str_ends_with. Since PHP 8.0 will be the minimum supported version in L9, it is only logical that their related functions in \Illuminate\Support\Str class get updated as well. Here is the PR that made it all happen!

The Latest Version of Spatie's Ignition Will Be Made Default
The announcement was made in a tweet by Spatie's Freek Van der Harten:

🚀 I'm proud to share that our team has released a new major version of Ignition. It's the most beautiful error page you ever seen, and it will be the default in @laravelphp 9

👍You can also install it in Laravel 8!

🧵 Let's take a look at all the features pic.twitter.com/jw9Dqdse9T

— Freek Van der Herten 🔭 (@freekmurze) January 18, 2022 " data-card-controls="0" data-card-theme="light">
🚀 I'm proud to share that our team has released a new major version of Ignition. It's the most beautiful error page you ever seen, and it will be the default in @laravelphp 9

👍You can also install it in Laravel 8!

🧵 Let's take a look at all the features pic.twitter.com/jw9Dqdse9T

— Freek Van der Herten 🔭 (@freekmurze) January 18, 2022
A New Option For The artisan test Command
Nuno Maduro announced in a tweet that the artisan test command will have a --coverage option in L9 that will instruct the test command to display the test coverage directly on the terminal.

In @laravelphp v9.x, we will be introducing the artisan test --coverage option. This option displays the test coverage directly on the terminal. 💫 pic.twitter.com/yKAMFwvwaZ

— Nuno Maduro (@enunomaduro) January 18, 2022 " data-card-controls="0" data-card-theme="light">
In @laravelphp v9.x, we will be introducing the artisan test --coverage option. This option displays the test coverage directly on the terminal. 💫 pic.twitter.com/yKAMFwvwaZ

— Nuno Maduro (@enunomaduro) January 18, 2022
This post is a work-in-progress. I will continue to update it as I get more information regarding Laravel 9.0 release. Thank you!

This post is a work-in-progress. I will continue to update it as I get more information regarding Laravel 9.0 release. Thank you!

Top comments (2)

Collapse
 
pathros profile image
Pathros • Edited

Very informative!
Do you have so far any idea about how long it will take to upgrade a L8 to L9 project?

Collapse
 
frknasir profile image
Faruk Nasir

Thank you. Generally, It shouldnt take more than the usual 15 mins. I tried the beta-3 release with a SaaS product I am maintaining and It didnt take me more than that.