Laravel 11 is now released!

Last updated on by

Laravel 11 is now released, including a minimum PHP v8.2, a new Laravel Reverb package, streamlined directory structure, and more...

Laravel Reverb

Laravel Reverb is a new first-party WebSocket server for Laravel applications, bringing real-time communication between client and server. Some of the features of Reverb include.

Blazing Fast

Reverb is fine-tuned for speed. A single server can support thousands of connections and piping data without the delay and inefficiency of HTTP polling.

Seamless Integration

Develop with Laravel's broadcasting capabilities. Deploy with Reverb's first-party Laravel Forge integration. Monitor with baked-in support for Pulse.

Built for Scale

Infinitely increase capacity by utilizing Reverb's built-in support for horizontal scaling using Redis, allowing you to manage connections and channels across multiple servers.

Pusher

Reverb utilizes the Pusher protocol for WebSockets, making it immediately compatible with Laravel broadcasting and Laravel Echo.

Streamlined Directory Structure

On a fresh install, the file count has dropped by ~ 69 files. Nice.

Check out our post on this complete new Laravel 11 Directory Structure

  • 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),
];
}

New Dumpable Trait

This aims to streamline the core of the framework since multiple classes currently have "dd" or "dump" methods. Plus you can use this Dumpable trait in your own classes:

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

Read more about the new Dumpable Trait.

Config Changes

Laravel has a lot of config files, and Laravel 11 removes these, and all config options cascade down. The .env has been expanded to include all the options you'd want to set.

Read more about the config changes.

New Once method

Laravel 11 includes a new once helper method that ensures you'll always get the same value no matter how many times you call an object method. The once function is helpful when you have some code that you want to ensure only ever runs one time.

Slimmed default Migrations

When you start a new Laravel app, it comes with some default migrations from 2014 and 2019. These now will come with the dates removed and moved into just two files.

Watch our Instagram Reel

Routes changes

By default, there will be only two route files, console.php and web.php. API routes will now become opt-in via php artisan install:api, giving you the API routes file and Laravel Sanctum.

The same with websocket broadcasting, php artisan install:broadcasting.

New up Health Route

Laravel 11 will include a new /up health route that fires a DiagnosingHealthEvent so you can better integrate with up time monitoring.

APP_KEY Rotation

In older versions of Laravel, if you changed your APP_KEY it could lead to broken data in the database. Laravel 11 has a new graceful rotation which will NOT break old encrypted data, using an APP_PREVIOUS_KEYS comma-delimited list .env variable. It will auto re-encrypt the data using new key.

Console Kernel Removed

The Console Kernel is being removed, and you'll be able to instead define your console commands right in routes/console.php.

Named Arguments

Named arguments are not covered by Laravel's backwards compatibility guidelines. They may choose to rename function arguments when necessary in order to improve the Laravel codebase. When calling Laravel methods using named arguments should be done cautiously and with the understanding that the parameter names may change in the future.

Eager Load Limit

Laravel 11 integrates the code behind the "eager load limit" package:

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

Read more about Eager Load Limit here.

New Artisan Commands

New Artisan commands have been added to allow the quick 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

Along with major updates to Laravel, we'll get a new welcome page when creating a new Laravel application.

When will Laravel 11 be released?

Laravel 11 will be released on March 12, 2024

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.

SQLite 3.35.0+ required

If you use a SQLite database, then Laravel 11 will require SQLite 3.35.0 or greater.

Doctrine DBAL Removal

Laravel is no longer dependent on the Doctrine DBAL and registering custom Doctrines types is no longer necessary for the proper creation and alteration of various column types that previously required custom types.

Install Laravel 11

The easiest way to install Laravel 11 is to first set up the Laravel Installer

composer global require laravel/installer

Then run:

laravel new projectname

Upgrade to Laravel 11

Laravel Shift is the easiest way to upgrade but you can also follow the upgrade guide in the Laravel docs

Laravel Support Policy

For all Laravel releases, bug fixes are provided for 18 months and security fixes are provided for 2 years. For all additional libraries, including Lumen, only the latest major release receives bug fixes.

Version PHP (*) Release Bug Fixes Until Security Fixes Until
Laravel 9 8.0 - 8.2 February 8th, 2022 August 8th, 2023 February 6th, 2024
Laravel 10 8.1 - 8.3 February 14th, 2023 August 6th, 2024 February 4th, 2025
Laravel 11 8.2 - 8.3 March 12th, 2024 September 3rd, 2025 March 12th, 2026
12 8.2 - 8.3 Q1 2025 Q3, 2026 Q1, 2027

Wrapup

So far, all these features are considered beta for Laravel 11 and are designed to improve your workflow. Things can and probably change, and we will keep this post updated as new features are announced.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Laravel Idea for PhpStorm logo

Laravel Idea for PhpStorm

Ultimate PhpStorm plugin for Laravel developers, delivering lightning-fast code completion, intelligent navigation, and powerful generation tools to supercharge productivity.

Laravel Idea for PhpStorm
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate logo

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate

Build your SaaS application in hours. Out-of-the-box multi-tenancy and seamless Stripe integration. Supports subscriptions and one-time purchases, allowing you to focus on building and creating without repetitive setup tasks.

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate
JetShip - Laravel Starter Kit logo

JetShip - Laravel Starter Kit

A Laravel SaaS Boilerplate and a starter kit built on the TALL stack. It includes authentication, payments, admin panels, and more. Launch scalable apps fast with clean code, seamless deployment, and custom branding.

JetShip - Laravel Starter Kit
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
URI Parsing and Mutation in Laravel 11.35 image

URI Parsing and Mutation in Laravel 11.35

Read article
Securing Laravel Sessions with ID Regeneration image

Securing Laravel Sessions with ID Regeneration

Read article
Paginate Multiple Eloquent Models with the Union Paginator Package image

Paginate Multiple Eloquent Models with the Union Paginator Package

Read article
Whisper.php - Automatic speech recognition and transcription image

Whisper.php - Automatic speech recognition and transcription

Read article
Multiple Column Plucking in Laravel Collections image

Multiple Column Plucking in Laravel Collections

Read article
File Manager Package for Livewire image

File Manager Package for Livewire

Read article