Preloader

Hold Tight & Blame the Internet!!

An overview of the upcoming features in Laravel 11
Laravel

An overview of the upcoming features in Laravel 11

blog
24 Jan 2024
830+

people have read this article

Streamlined Directory Structure

So far, these are just a beta preview. They might change, but as of now, here is what to expect...

Controllers no longer extend anything by default.

No more middleware directory. Currently, Laravel includes nine middleware and many you would never customize. However, if you do want to customize them, that is moved to the App/ServiceProvider. For example:

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

No more Http/Kernel

Most of the things you used to could do in the Kernel you can now do 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):
    })

Model casts changes

Model casts are now defined as a method instead of a property. When defined as a method we can do other things, like call other methods directly from the casts. Here is an example using a new Laravel 11
AsEnumCollection:

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

PHP 8.2 minimum support

This was an early decision, but Laravel 11 apps require a minimum of PHP 8.2. If you are running an older version of PHP, now is a good time to get that upgraded.

Install Laravel 11

Laravel 11 isn't released yet, but you can start using it and testing it by running Laravel new with the --dev flag:

laravel new projectname --dev
Source: https://laravel-news.com/