Laravel 11 is Released – New enhancements and Features!

By: Skynet Technologies USA LLC
8 mins
500
Laravel 11 Release

Laravel 11 is released on March 12, 2024. According to Laravel support policy, Laravel 10 will be officially active till February 4, 2025, and Laravel 11 will receive bug fixes till September 3, 2025, and security fixes till March 12, 2026. Thus, the existing Laravel applications can be upgraded in sometime after understanding the need of upgradation.

Nevertheless, the Laravel 11 has come up with numerous exciting features and updates. The latest version will support a minimum of PHP 8.2. A new Laravel Reverb package and a defined directory structure are new additions that will be seen in Laravel 11.

As announced by makers, Laravel 11 includes support for graceful encryption key rotation and a minimal application structure. It uses SQLite by default, implements health routing, improves queue testing, adds Resend mail transport, and integrates a Prompt validator, and there are several useful improvements.

Let’s explore!

New features of Laravel 11!

  • Laravel Reverb

    Laravel Reverb is a newly introduced first party WebSocket server for Laravel applications. It will initiate real-time communication between the client and server. It is meant for speed; thousands of connections and piping data can be supported by a single server, which ultimately reduces the delay of HTTP polling.

    This new enhancement can be deployed with Reverb’s first party Laravel Forge Integration to monitor in-built support for Pulse.

    Since Reverb has baked-in support for horizontal scaling using Redis, it increases the capacity of the system to manage connections and channels for multiple servers.

    Laravel Reverb is compatible with Laravel Broadcasting and Laravel Echo because it utilizes Pusher protocol for WebSockets.

  • No more HTTP/Kernel

    The kernel is no longer needed to perform tasks instead they can be done in the Bootstrap/App.

    return Application::configure()
    ->withProviders ()
    ->withRouting(
        web: __DIR__.'/../routes/web.php'
        commands: __DIR__.'/../routes/console.php',
      )
    ->withMiddleware(function(Middleware Smiddleware) {
      $middleware->web(append: LaraconMiddleware::class):
    })
  • Streamlined Directory Structure

    Laravel 11 eliminates the middleware directory and Controllers don’t extend anything by default. Till Laravel 10.x, nine middleware were present and some of them were never utilized by developers. However, they are still available at different places (App/Service Provider) if needed for customization.

    For instance:

    public function boot(): void {
      EncryptCookies::except(['some_cookie']);
    }
  • New Dumpable trait

    This addition is intended to improve the core of the framework because there are several classes that have “dd” or “dump” methods. Additionally, this Dumpable trait is useful for creating own classes.

    class Stringable implements JsonSerializable, ArrayAccess {
      use Conditionable, Dumpable, Macroable, Tappable;
      str('foo')->dd();
      str('foo')->dump();
  • Model Casts changes

    Model casts are methods and not property; thus, now the methods can be directly called from the casts. For instance,

    protected function casts(): array {
      return [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
        'options'=› AsEnumCollection::of(UserOption::class),
      ];
    }
  • Config Changes

    Until now Laravel had myriad config files; Laravel 11 removed those files and cascaded down all config options. The .env file has been increased so that all options can be included that are required to set.

  • Slimmed default migrations

    The New Laravel app included some default migrations from 2014 and 2019. However, now these will come with dates removed and moved to two files only.

  • New Once Method

    The new version of Laravel introduces a new once-helper method to ensure that no matter how many times an object is called, its return value will be the same. This function is helpful when certain code is decided to run only once.

  • Route changes

    There will be only two route files, console.php and web.php. API routes will now become opt-in through php artisan install:api, ensuring the API routes file and Laravel Sanctum.

  • APP_KEY rotation

    Laravel older versions tend to break data in the database if APP_KEY is changed. Laravel 11 has a new graceful rotation that will not break old, encrypted data, using an APP_PREVIOUS_KEYS comma-delimited list.env variable. It will use a new key to auto re-encrypt the data.

  • New up health route

    To fire a DiagnosingHealthEvant, Laravel 11 will contain a new ‘/up’ health route. It will improve uptime monitoring process.

  • Console Kernel removed

    The Console Kernel is being eliminated from Laravel 11. So, defining specific console commands right in routes/console.php is possible now.

  • Eager Load Limit

    Laravel 11 will integrate the code behind the Eager Load Limit package -

    User::select('id', 'name')->with([
      'articles' => fn($query) => $query->limit(5)
    ])->get();
  • Named arguments

    Laravel’s backward compatibility guidelines don’t cover Named arguments. Thus, they may choose to rename function arguments to fine-tune the Laravel codebase, if required. When calling Laravel methods using named arguments must be done cautiously and with the understanding that the parameter names may change in the future.

  • New Artisan Commands

    This feature has been added in Laravel 11 to ensure the swift creation of classes, enums, interfaces, and traits -

    php artisan make:class
    php artisan make:enum
    php artisan make:interface
    php artisan make:trait
  • New welcome page

    A new welcome page is another important update shipping along with Laravel 11 to create new Laravel applications.

  • PHP 8.2 minimum support

    Laravel 11 apps will need a minimum of PHP 8.2 version. So, to leverage this latest version’s advancements, upgrading PHP is essential.

  • SQLite 3.35.0+ is needed

    For the SQLite database, Laravel 11 needs its 3.35.0 or greater version to execute all its features and upgrades.

  • Doctrine DBAL removal

    The latest Laravel version is not dependent on Doctrine DBAL. Also, registering custom Doctrine types for the creation and alteration of various column types is not required, that are previously needed custom types.

YOU MAY ALSO LIKE: Laravel Security Best Practices

Either install or upgrade to Laravel 11 to reap more benefits!

To install Laravel 11, set up the Laravel Installer:

composer global require laravel/installer

And then run:

laravel new projectname

To upgrade the older Laravel version to the new Laravel 11, adhering to the Laravel Shift is the simplest way. However, there is an upgrade guide available in the official docs.

Though Laravel 10 will receive security fixes till February 2025, there is no harm in upgrading to Laravel 11. It will be always beneficial for existing Laravel applications to be able to leverage newly added features in Laravel 11.

Ready to level up your projects with Laravel 11? You can count on us if you need a custom Laravel solution or a hire Laravel developers . Whether you're looking for developing new applications, upgrading existing ones, or migrating from earlier versions, our expert team is here to guide you. For more information, reach out [email protected].

97