Laravel 11 Now Available

Mar, 12 2024#releases

Today, we're thrilled to announce the release of Laravel 11 and Laravel Reverb.

image

As we announced at Laracon EU, Laravel 11 introduces a minimal application structure, using SQLite by default, implementing health routing, offering per-second rate limiting, supporting graceful encryption key rotation, improving queue testing, introducing new Artisan commands, adding Resend mail transport, integrating Prompt validator, and more. Check out our Founder and CEO, Taylor Otwell, live demonstrating what's new in Laravel 11:

Watch the video

Reverb is the latest addition to the Laravel ecosystem and is a first-party, scalable WebSocket server that has been introduced to provide robust real-time capabilities to your applications.

To get all of the juicy details about this release, check out our official release notes and upgrade guide. Below, we'll cover some of the highlights.

Minimal Application Structure

Laravel 11 introduces a minimal application structure for new Laravel applications, without requiring any changes to existing applications. The new application structure is intended to provide a leaner, more modern experience, while retaining many of the concepts that Laravel developers are already familiar with.

The app folder has been massively simplified; both the HTTP and Console kernels have been removed. The nine middlewares that were rarely customized have now been moved into the framework itself, the exception handler has been removed, and the Providers directory has been streamlined to a single provider.

Here is what the new app folder looks like:

image

Rest assured, customization remains a priority. To adjust the high-level application behavior settings, you can utilize the revitalized bootstrap/app.php file. This file allows you to modify your application's routing, middleware, service providers, exception handling, and more:

image

In addition, the routes folder has been simplified; the api.php and channels.php route files are no longer present by default, since many applications do not require these files.

image

Instead, they can be created using simple Artisan commands:

php artisan install:api

php artisan install:broadcasting

And there's more! There are numerous details about Laravel's new application structure that we can't cover in this blog post. Make sure to check out our release notes to learn everything about it.

Laravel Reverb

Laravel Reverb brings blazing-fast and scalable real-time WebSocket communication directly to your Laravel application, and provides seamless integration with Laravel’s existing suite of event broadcasting tools, such as Laravel Echo.

Futhermore, Reverb supports horizontal scaling via Redis's publish / subscribe capabilities, allowing you to distribute your WebSocket traffic across multiple backend Reverb servers all supporting a single, high-demand application.

Here is an example of a stress test with ~30,000 clients maintaining open connections to Reverb, where each connection is subscribed to 10 different channels, and more than 6,000 messages are being exchanged per second:

image

Additionally, you may monitor the performance of your Reverb servers in Laravel Pulse to get a better understanding of the number of connections and messages being handled. To dig deeper into Laravel Reverb, please consult the complete Reverb documentation.

SQLite By Default

By default, new Laravel applications use SQLite for database storage, as well as the database driver for Laravel's session, cache, and queue. Furthermore, creating a project using composer create-project command or through the Laravel Installer will automatically create the SQLite file and run the initial database migrations for you:

image

This allows you to begin building your application immediately after creating a new Laravel application, without being required to install additional software or create additional database migrations.

Health Routing

New Laravel 11 applications include a health routing directive, which instructs Laravel to define a simple health-check endpoint that may be invoked by third-party application health monitoring services or orchestration systems like Kubernetes. By default, this route is served at /up:

image

When HTTP requests are made to this route, Laravel will dispatch a DiagnosingHealth event, allowing you to perform additional health checks relevant to your application, such as verifying database connectivity and ensuring the cache is working as expected.

Queue Interaction Testing

Previously, attempting to test that a queued job was released, deleted, or manually failed was cumbersome and required the definition of custom queue fakes and stubs. However, in Laravel 11, you may easily test for these queue interactions using the withFakeQueueInteractions method:

image

Besides the assertReleased assertion, which you can use to verify if a job was released back into the queue, you may also use the assertFailed or assertDeleted assertions to determine if a job has failed or been deleted, respectively.

Graceful Encryption Key Rotation

Since Laravel encrypts all cookies, including your application's session cookie, essentially every request to a Laravel application relies on encryption. However, because of this, rotating your application's encryption key would log all users out of your application. In addition, decrypting data that was encrypted by the previous encryption key becomes impossible.

Laravel 11 allows you to define your application's previous encryption keys as a comma-delimited list via the APP_PREVIOUS_KEYS environment variable:

image

When encrypting values, Laravel will always use the "current" encryption key, which is within the APP_KEY environment variable. When decrypting values, Laravel will first try the current key. If decryption fails using the current key, Laravel will try all previous keys until one of the keys is able to decrypt the value.

This approach to graceful decryption allows users to keep using your application uninterrupted even if your encryption key is rotated.

For more information on encryption in Laravel, check out the encryption documentation.

And So Much More

There are so many more improvements and new features in Laravel 11 that we can't cover in this post:

We encourage you to check out the release notes and upgrade guide for more information on the new features and improvements in Laravel 11.

Finally, we would like to thank the Laravel community for their contributions to this release. We are truly grateful for the time and effort that so many of you have dedicated to making Laravel 11 a reality.

We hope you enjoy the new release and look forward to seeing the amazing applications you build with Laravel 11.0!

By Taylor Otwell

Creator of Laravel.

Follow the RSS Feed.