whats new in laravel
Indrajith . 5 minutes

What’s new in Laravel 11: New Features and Changes

Laravel 11 is here! Laravel 11 was released in March 2024. This latest release introduces a focus on streamlining the development process and introducing powerful new features. We’ll explore how Laravel 11 empowers you to build modern web applications faster and more efficiently. In this article let’s take a look at some of the new features and updates of Laravel 11.

Laravel is a powerful and popular PHP framework used for developing web applications. It follows the MVC (Model-View-Controller) architectural pattern, which helps in organising code and improving application performance. Laravel provides a wide range of features and functionalities that make web development faster and more efficient. 

New Features and Updates of Laravel 11

Simple Application Structure

Without requiring any modifications to already-existing apps, Laravel 11 delivers a simplified application framework for new Laravel applications. Though many of the features are familiar to Laravel developers, the new application structure aims to offer a more contemporary and lighter experience.

Centralized Configuration

  • The bootstrap/app.php file becomes your one-stop shop for configuring core application aspects like routing, middleware, service providers, and exception handling.
  • This replaces the scattered approach of previous versions, making everything more organized and easier to find.

Streamlined Service Providers

Laravel 11 introduces a single AppServiceProvider, Functionality from the old providers is either:

  • Built into bootstrap/app.php
  • Handled automatically by Laravel
  • Placed in your AppServiceProvider for custom control.

Automatic Event Discovery

  • Event discovery is now enabled by default, saving you time and effort.
  • Manual event and listener registration are largely unnecessary.
  • You can still register events manually in AppServiceProvider if needed.

Optional API and Broadcast Routing

  • api.php and channels.php are no longer included by default.
  • If you need them, simply generate them using php artisan install:api and php artisan install:broadcasting.

Built-in Middleware

  • The nine default middleware (authentication, input trimming, CSRF, etc.) are now part of the Laravel framework itself.
  • This reduces clutter in your application structure.
  • You can still customize middleware behaviour through bootstrap/app.php.
  • For example, you can exclude specific routes from CSRF protection.

No More HTTP Kernel

Since middleware is centralized, the separate HTTP “kernel” class is no longer needed.

Health Routing

Laravel 11 introduces a new way to monitor your application’s health: health routing.

  • Built-in Endpoint: New Laravel applications automatically include a health check endpoint at /up.
  • Third-Party Monitoring: This endpoint can be accessed by external tools like application health monitoring services or orchestration systems (e.g., Kubernetes) to verify your application’s status.
  • Customizable Checks: The default behaviour simply returns a successful response, but you can do more!
  • DiagnosingHealth Event: When a request hits /up, Laravel triggers a DiagnosingHealth event.
  • Tailored Checks: This event allows you to perform additional health checks specific to your application’s needs. For example, you could check database connectivity, cache status, or queue processing.

Encryption Key Rotation

In Laravel, all cookies, including the session cookie, are encrypted. Changing the encryption key logs users out and makes old data decryption impossible. 

Laravel 11 lets you define previous encryption keys using the APP_PREVIOUS_KEYS variable. When encrypting, Laravel uses the current key (APP_KEY); for decryption, it tries the current key first and then the previous keys if needed. This ensures uninterrupted use during key rotations. Check Laravel’s encryption docs for more details.

Laravel Reverb

Laravel reverb makes integration easier with Laravel’s event broadcasting tools, like Laravel Echo.

Using the command php artisan reverb:start, Reverb starts working.

Reverb supports horizontal scaling with Redis’s publish/subscribe capabilities. By doing this, you can distribute WebSocket traffic among several backend Reverb servers, each of which can host a single, frequently used application.

PHP 8.1 will not be supported

The most recent version of PHP is 8.3, with PHP 8.2 being the established version. Laravel may now proceed and drop support for 8.1.

Queue Interaction Testing

Before Laravel 11, testing queued job releases, deletions, or manual failures was complex, needing custom queue fakes and stubs. In Laravel 11, you can easily test these queue interactions using the withFakeQueueInteractions method:

This simplifies the testing process significantly.

Automatic Password Rehashing

Laravel uses bcrypt as its default password hashing algorithm. You can adjust the “work factor” for bcrypt hashes either through the config/hashing.php configuration file or by setting the BCRYPT_ROUNDS environment variable.

It’s recommended to increase the bcrypt work factor periodically as CPU/GPU processing power improves. When you increase the bcrypt work factor for your application, Laravel will automatically and smoothly rehash user passwords as they authenticate with your application.

Conclusion

Finally, Laravel 11 marks an important turning point in the development of the Laravel framework. For further information, you can refer to Laravel documentation. Laravel keeps coming up with new features and innovations with every release. This gives developers the tools and resources they need to create scalable and reliable online applications. The Laravel community is still thriving and active, offering helpful tools, documentation, and assistance to make sure developers can take full use of Laravel 11. Hire Laravel developers to enhance your businesses and move forward with Laravel development services projects confidently.

What are the key features of Laravel 11?

Laravel 11 includes a simplified structure, centralized configuration, streamlined service providers, automatic event discovery, optional API and broadcast routing, built-in middleware, health routing, encryption key rotation, Laravel Reverb, and improved queue interaction testing.

How does Laravel 11 simplify application development?

Laravel 11 simplifies development with its streamlined structure, centralized configuration, and automatic event handling.

What is the significance of centralized configuration?

Centralized configuration in Laravel 11 simplifies the management and organization of core application aspects.

How does Laravel 11 handle Automatic event discovery?

Laravel 11 automatically discovers and handles events, reducing the need for manual registration.

What improvements does Laravel 11 bring to password rehashing?

Laravel 11 enhances password security with automatic rehashing and adjustable bcrypt work factor.

blog
Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Arsha Contact

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.