New Features in Laravel 11: What Web Developers Need to Know


This article provides information about the upcoming changes in Laravel 11. Please note that this is still a beta preview and changes are possible at any time. The article will be updated as new information or changes are known.

Simplified Directory Structure

One of the first things you'll notice is the revised and simplified directory structure of Laravel. By default, controllers no longer extend anything and the middleware directory has disappeared. Laravel currently includes nine middleware, many of which you would probably never modify.

However, if you want to adjust them, you can now find the corresponding functions in the App/ServiceProvider:

public function boot(): void

Changes to Model Casts

Model Casts are now defined as methods rather than properties. This allows you to call additional functions, such as other methods directly from the Casts. Here is an example using the new Laravel 11 AsEnumCollection:

protected function casts(): array
    return [
        'user_verified_at' => 'datetime',
        'password' => 'hashed',
        'options' => AsEnumCollection::of(UserOption::class),

No More Http/Kernel

Many of the functions that you have implemented in the Kernel can now be defined in the Bootstrap/App.

return Application::configure()
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
    ->withMiddleware(function(Middleware $middleware) {
        $middleware->web(append: LaraconMiddleware::class);

Changes in Configuration

Laravel 11 reduces the number of configuration files by cascading all configuration options. The .env has been expanded and now includes all the options you want to set.

With the new config:publish command, you can retrieve any configurations you might miss. Even then, the new cascading feature allows you to remove any option you do not want to adjust.

Changes to Routes

By default, there are now only two route files: console.php and web.php. API routes can now optionally be added via php artisan install:api, which gives you the API route file and Laravel Sanctum. The same applies to the WebSocket transmission with php artisan install:broadcasting.

The Console Kernel is Removed

The Console Kernel is removed in Laravel 11. You will be able to define your console commands directly in routes/console.php.

Streamlined Default Migrations

When you start a new Laravel app, some default migrations from 2014 and 2019 are included. These are now provided without a date and consolidated into just two files.

Minimum Support for PHP 8.2

An important decision made early on: Laravel 11 requires at least PHP 8.2. So if you're still using an older version of PHP, now is a good time for an upgrade.