Features of Laravel 9

The new version of Laravel 9 is released on 8 February 2022, it’s an LTS version of Laravel. In this article, we will discuss the features of Laravel 9. No introduction is required for Laravel, it’s a mostly used PHP framework for a long time now.

Laravel Support Policy

Laravel 9 provides long-term support, similar to Laravel 6. It’s an LTS version so Laravel 9 will provide the longest maintenance and support guidance. You will get two years of support to fix bugs, which will remain until February 2024. For Security support, it will be for three years which will last till 2025. Please check the following.

Read more on support policy here.

Minimum requirement of PHP 8.

Laravel, as a framework, depends on several community-driven and Symfony 9 libraries. As Symfony planned to release v6.0 by November 2021, that forced the Laravel team to delay the release of Laravel 9. This is the reason for the minimum requirement of PHP 8.

Anonymous Stub Migrations

In the latest version of Laravel, anonymous stub migration is a default behavior when you execute the popular migration command:

php artisan make:migration add_users_nick_name --table=users

The stub migration feature eliminates migration class name collisions. For example, the migration class looks like the following:

<?php

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('users', function (Blueprint $table) {
            $table->string('nick_name')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('nick_name');
        });
    }
};

New Query Builder Interface

Laravel 9 provides New Query Builder Interface, making it easier for developers to work with. Laravel 9, type hinting is exceedingly reliable for refactoring, inactive analysis, and code completion in their IDEs. That’s due to the need for a shared interface or inheritance between QueryBuilder, EloquentBuilder, and EloquentRelation. Developers can take advantage of the new query builder interface type hinting, refactoring, and static analysis with Laravel 9.

PHP 8 string functions

PHP string function is one of the key features of Laravel 9 to look after because this new version is more focused on using PHP 8.0 and its string function that includes str_contains(), str_starts_with(), and str_ends_with().

Swift Mailer to Symphony Mailer

Swift Mailer is replaced with the Symfony Mailer, which provides more consistency to your application. Symfony deprecated the Swift Mailer and introduced the Symfony Mailer. Because Laravel mostly depends on the Symfony component so Laravel 9 is shifted to Symfony mailer.

Default HTTP Client Timeout

HTTP clients default timeout in 30sec. This step will help avoid hangs occurring in the Laravel previous versions.

In other words, in case the server does not respond within 30 seconds, an exception will be tossed. Already, no default timeout length was arranged on the HTTP client, causing requests to sometimes “hang” indefinitely. If you wish to specify a longer timeout for a given request, you may do so using the timeout method:

$response = Http::timeout(120)->get(...);

New Design

Route List

Laravel 9 provides a new design for the route list. So when we use the following command:

php artisan route:list

After that terminal looks like.

Exception

Exception page theme has been improved. With this exponential feature, you can customize or choose available themes at your convenience.

Conclusion

In this article, we are discussing some features of Laravel 9. Hope this will gave you some exposure to Laravel 9. Please feel free to add comments if any queries or send your feedback.

Keep learning & stay safe 😉

If you like our content, please consider buying us a coffee.
Thank you for your support!
Buy Me a Coffee

LaravelLaravel 9
Comments (0)
Add Comment