What’s new in Laravel 11?
Although the Laravel 11 is not released officially, certain new features have already been unveiled. During Laracon(July 2023) keynote, Taylor Otwell discussed significant improvements and updates that will be included in Laravel 11.
Change is directory structure
In Laravel 11, the middleware directory will no longer exist. Currently, Laravel comes with nine middleware, and most of them are unlikely to be customized. However, if you do wish to customize any middleware, you can now do so within the App/ServiceProvider.
For example:
public function boot(): void
{
EncryptCookies::except(['some_cookie']);
}
Change is config
In Laravel 11, there have been significant changes to the configuration system. Instead of having numerous config files, Laravel now adopts a cascading approach, where all configuration options are inherited from a higher level. The .env file has been enhanced to encompass all the necessary settings you may wish to configure.
Furthermore, Laravel 11 introduces a new “config:publish” command, enabling you to retrieve specific configurations that you need. This newfound cascading feature allows you to easily eliminate any options you don’t want to customize, ensuring a more streamlined and tailored configuration experience.
Routes related change
As a default setting in Laravel, there will be two route files: console.php and web.php. If you want API routes to be included, you’ll need to opt-in by running “php artisan install:api” which will provide you with the API routes file and Laravel Sanctum functionality.
Similarly, for websocket broadcasting, you can enable it using “php artisan install:broadcasting.” This command will set up the necessary files and configurations for websocket broadcasting in your Laravel application.
Say bye to Console Kernel
Currently all of your console commands are registered within your application’s
App\Console\Kernel
class, which is your application's "console kernel".
In Laravel 11, The Console Kernel is no longer required, and instead, you can directly define your console commands within the routes/console.php file.
PHP Version Requirement
Laravel 11 applications now have a minimum PHP version requirement of 8.2.
Up to this point, all the mentioned features in Laravel 11 are classified as beta and have been introduced to enhance your workflow. It’s essential to note that these features are subject to further adjustments and improvements, and we will continue to update this post as new features are announced.
If you like this article make sure to clapp-clapp 👏 and follow me on Medium for more such articles. Suggestions in the comments are always welcome :)
Since content generation is not an easy process, I wouldn’t mind if you supported me by gifting me a Ko-fi to motivate and boost my confidence :)