What’s New in Laravel 11

Laravel 11

Laravel 11 comes with new updated features aimed at easing developer productivity and optimizing application performance. With enhancements in configuration, debugging, and flexibility, this release is designed to enhance development efficiency, enabling you to construct more resilient applications. Let’s explore these advancements!

Minimum PHP 8.2 version is needed

To run laravel 11 application, you will need PHP 8.2 version installed on your system. Laravel 11 boosts performance, security, and developer experience by accommodating the latest two major PHP versions. By setting PHP 8.2 as the minimum requirement, it ensures future compatibility for your projects and enables the utilization of the language’s complete capabilities.

The New Directory Structure

Laravel 11 restructured the directories to motivate simple code organising without code redundancy. It has removed app/Exceptions and app/Http/Middleware directories. Earlier version has 9 middlewares, many of those you rarely customised. This helps you to focus on much needed middleware only and reduces unused code. Still if you want to customise the middleware, you can do it via App/ServiceProvider.

Major change in laravel 11 is it has removed config folder.

Model casts using casts()

With Laravel 11, you specify model casts in a method named casts(). Including casting logic within methods makes your code more modular and reusable. It will also make code more reusable and readable regarding code maintenance. You can seamlessly transition your existing codebases to use Laravel 11’s updated model casting approach as it supports backward compatibility.

Simple Configurations

As noted earlier, laravel 11 removed config directory and moved all config settings to single place, that is to .env file. You can also remove options from config file if you don’t want to override it.
The consolidated .env file eliminates the necessity for multiple files by centralizing all relevant configurations in one location. Nonetheless, if you find the .env file becoming excessively large, you can utilize a command to relocate the configuration file to the config directory. For instance, executing php artisan config:publish auth generates the auth.php file within the config directory.

New Dumpable trait added

It’s important to note that the Dumpable trait is expected to take over the current dd() and dump() methods in numerous core classes of Laravel. This shift is intended to create a uniform and cohesive debugging experience across the entire framework.

Route Handling Improved and Simplified

It reduces the default number of route files from four to two: routes.php and console.php. This alteration has a significant impact as it decreases the amount of boilerplate code and enhances the overall intuitiveness of the framework.

If you want to add api routes in your application, you have to run php artisan install:api command which will add api.php route file.

Similarly, if you want to enable even broadcasting, you need to explicitly run php artisan install:broadcasting command to add channel.php file.

Update In Laravel HTTP Kernel

In Laravel 11, the Laravel kernel is eliminated. Instead, the Bootstrap/App class is used, binding crucial interfaces into the container. Once the essential components are configured, the Bootstrap/App class yields the application instance. This division between instance creation and the execution of the application and response handling results in a more modular architecture.

Upon the initiation of an application instance, the Bootstrap/App class oversees the handling of essential web requests, streamlining the development process and fostering a more structured codebase.

These are some features that Laravel 11 version may offer which is subject to change. I hope you like the article!

Leave a Reply

Your email address will not be published. Required fields are marked *