Blog

What's going on, in and out

laravel-11-released

Laravel 11 Released – What’s New in Upgrade Version?

The Laravel PHP framework’s new update was released on March 12, 2024. The new version, Laravel 11, includes various changes focused on security and performance enhancements. 

The Laravel upgrade team follows the Semantic Versioning methodology and releases new versions in the first quarter of every year. This means that if you have recently switched to an update of the PHP framework, you need not be in a hurry to deploy this Laravel release.

Using Laravel 11 requires installing a minimum of PHP v8.2. The update also includes a new Laravel Reverb package, a streamlined directory structure, and various outstanding features.

Here are 10 Major Changes Developers Can Access with Laravel 11

1. Introducing Laravel Reverb Web Socket

The Laravel upgrade comes with a brand new first-party WebSocket server for applications. The advanced server ensures smooth real-time communication between the client and the server and is fine-tuned to provide high-speed performance. 

The key features of Laravel Reverb are:

  • Each server can support thousands of connections. Additionally, each server can pipe data with zero delay and eliminate the performance issue of HTTP polling.
  • It has been created with  Laravel’s broadcasting capabilities. 
  • Laravel applications can now use Reverb’s built-in support for horizontal scaling via Redis. This means developers can seamlessly manage connections and channels across multiple servers.
  • The web socket deploys Pusher protocol, which makes it compatible with Laravel broadcasting and Laravel Echo.

2. Straightforward Directory Structure

For fresh installations, developers can experience a drop in file counts of 69 files compared to earlier Laravel releases. Moreover, the default extension of controllers has been eliminated, and there’s zero middleware directory. 

Developers can customize the middleware by accessing them from the App/ServiceProvider section. An example of this is:

public function boot(): void
{
    EncryptCookies::except(['some_cookie']);
}

3. Model Casts Modification

The standard upgrade to Laravel 11 allows developers to define Model acts as methods instead of a property. This further means that model casts can call other methods directly from the casts, which helps with ensuring a straightforward server-side coding of the application. So, the calling Laravel methods with the new release have been simplified.

4. Support for PHP 8.1 & Previous Version Removed

Laravel 11 is fully established with PHP 8.2, and version 8.3 is also stable. As the framework upgrade supports two up-to-date versions of the PHP programming language, there’s no need to use an earlier or outdated version. 

Developers do not need to upgrade to the latest version instantly, but it is advisable to take a thorough testing approach. Businesses can continue with the current Laravel versions. However, an upgrade to Laravel 11 of the current apps can prove beneficial.

5. Integrated Dumpable Trait

The version comes with a dumpable trait that aims to streamline the core of the framework.  This is because various classes currently have “dd” or “dump” methods. Also, Laravel developers can deploy this Dumpable trait in custom classes of any of the configuration file. 

6. Health Routing

One of the critical features Taylor Otwell added to the Laravel codebase is the health routing directive. It is focused on defining a simple health-check endpoint. Third-party apps, health monitoring services, or orchestration systems like Kubernetes can invoke this endpoint. 

7. SQLite Database By Default

The latest Laravel version upgrade leverages SQLite for database storage. It also uses it along with the database driver for Laravel’s session, cache, and queue. This means developing an IT  project using the composer create-project command or via Laravel installer, which, in turn, will create the SQLite file and run the initial database migrations.

This ensures fast-paced application development. Laravel developers do not need to install add-on software or deploy additional database migrations.

8. Route Modification

The new version provides two route files by default, which are console.php and web.php. With these two routes, the API routing becomes opt-in via php artisan install:api. This in turn provides the API routes file and Laravel Sanctum.

The same is followed with websocket broadcasting, `php artisan install:broadcasting.` 

9. Experience Minimalistic Application Skeleton

Laravel 11 comes with a fairly slimmer skeleton, intended to minimize the use of boilerplate code. This approach ensures that business owners and Laravel developers can maintain a rapid-paced software development life cycle. 

The major modifications include the following:

  • Under the AuthServiceProvider, the ‘$policies’ are eliminated, as the latest framework upgrade automatically discovers them.
  • The ‘SendEmailVerificationNotification’ is no longer necessary in the ‘EventServiceProvider’ because the base ‘EventServiceProvider’ is registering it. 
  • ‘BroadcastServiceProvider’ is no longer required and has been removed.
  • ‘RedirectIfAuthenticated’ is simplified with the base one adjusted in the framework’s internals.
  • The ‘Authenticate’ middleware no longer calls the ‘redirect ()’ for the JSON routes, eliminating unnecessary ternary checks.
  • The Custom Artisan comes with automated loading, which means the console does not need to use the ‘load()’ method.
  • The routes/console.php is eliminated, and the closure-based artisan commands are available for registration only in the console kernel.
  • Several migrations have either been consolidated into a single file or have been totally removed.
  • The ‘AuthorizesRequests’ and ‘ValidatesRequests’ traits have been completely eliminated from the base controller.
  • The bootstrap/app.php file is smaller in size and comes with just three lines of code.
  • The exception handler is totally eliminated from Laravel v11.

Additionally, the whole middleware is removed from the skeleton structure, including the following: 

  • `EncryptCookies’
  • ‘PreventRequestsDuringMaintenance.php’
  • ‘TrimStrings’
  • ‘TrustHosts’
  • ‘TrustProxies’
  • ‘ValidateCsrfToken’
  • ‘ValidateSignature’

10. Console Kernel Removed

The Console Kernel has been eliminated, and developers can now define the console commands in routes/console.php.

Traditionally, the routes/console.php file is defined by the Artisan commands as closures. With this new amendment, it will now work as the primary location for registration of all console commands.

This simplifies the structure of any Laravel application and provides a more straightforward and consolidated way for console command management.

There are various more enhancements noticeable compared to previous Laravel versions like modification in the abstract class controller, exceptional handling, config directory, and more.

Wrapping Up

That was all about the new Laravel 11 upgrade release bug fixes, security fixes, and enhancements. If your application is running on an outdated or older version of the PHP framework, it’s time to leverage this update. 

As a leading Laravel development agency, we can ensure seamless application upgrade services. Our well-versed engineers have hands-on experience in various types of projects and can help you with hassle-free services. 

 

Share this blog