What's New Laravel 11?

What's New Laravel 11?

The introduction of Laravel 11 came with many new features and quality-of-life improvements, making development more efficient, smoother and simpler. Developers have much to look forward to with welcome changes to pre-existing configurations, making for a more intuitive experience.

Today, let's delve into the exciting new features and improvements that Laravel 11 has to offer.

Laravel Home Page
Laravel 11 features a new welcome page with light and dark mode

Frameworks and Version Requirements

Minimum PHP 8.2

Starting with Laravel 11, support for PHP 8.1 has been dropped in favour of PHP 8.2

Pest

From community feedback, the default testing framework Laravel uses has been changed to Pest.

SQLite

Laravel has switched to using SQLite as its default database, which will also require version 3.35.0+.

Simpler Project Structure

Project Structure

One of the more impactful changes in Laravel 11 is the new directory structure. A more minimalistic approach in favour of removing necessary clutter for less boilerplate and better code reusability. An example of this reduction is the decrease in default routes from 4 to 2. This can offer many benefits such as making navigation and collaboration smoother to improve efficiency across the project.

Configs

Previous versions of Laravel have an abundance of config files. Starting from Laravel 11, these config files have been removed and abstracted into a single .env file. As a result, this improves the organisation even further with the new project structure changes.

Laravel Rebverb

Laravel Reverb
“Brings blazing-fast and scalable real-time WebSocket communication directly to your Laravel application

Laravel Reverb is a new feature in Laravel 11, boasting seamless integration, that brings communication between the client and server in real-time. This means a single server can support many connections without any delay. Moreover, Reverb is built for scale, being able to infinitely increase capacity by utilising built-in support for horizontal scaling using Redis.

Quality-of-Life Changes in Laravel

What’s more? Laravel 11 introduces many quality-of-life changes to improve the productivity and intuitiveness of the framework.

Dumpable Trait

The new Dumpable trait intends to replace the dd() and dump() methods into a reusable component so classes won’t have to manually implement this feature. This allows Laravel developers to easily include debugging methods with real-time insights about a target object or variable by utilising this trait.

Health Route

Laravel 11 has also implemented a new health-check endpoint at /up, to ensure different parts of an application are running as intended.

OnceI() Method

A new helpful function, once(), ensures some code only ever runs one time. This function executes a “callback and caches the result in memory for the duration of the request”, and will return the the cached result on subsequent calls.

Eager Load Limit

Laravel 11 now integrates the Eager Load Limit’ package natively. This package can limit the number of eagerly loaded results per parent.

New Artisan Commands

And finally, some new Artisan commands have been introduced in the form of make:. This will make creating classes, enums, interfaces, and traits quicker.

php artisan make:class
php artisan make:enum
php artisan make:interface
php artisan make:trait

Beginning with Laravel 11 in Your Projects!

Laravel 11 brings a host of exciting new features and improvements, making development more efficient and intuitive. With changes to the framework requirements, the adoption of Pest as the default testing framework, and the use of SQLite as the default database, Laravel 11 is set to enhance your development experience.

The simpler project structure, including a reduction in config files and the introduction of Laravel Reverb for real-time WebSocket communication, further streamlines your workflow. Quality-of-life changes like the Dumpable trait, health route, once() method, eager load limit integration, and new Artisan commands make Laravel 11 a powerful tool for developers. We can't wait to see what this latest version has in store for our development work!

Post Details

Author: Phillipe Sebastiao

Categories:

WebSoftware DevelopmentCode

Updated: 06 Apr 2024

Interested in one of our products?

Get in touch and let us know how we can help! 😇