Latest Features in Laravel 11 Update

Latest Features in Laravel 11 Update

Latest Features in Laravel 11 Update

Laravel 11, the upcoming version of the popular PHP framework, is expected to bring several exciting features and changes. Here are some of the anticipated updates based on the information available as of now: 

1. Release Date: Laravel 11 is scheduled to be released on February 6th, 2024, according to the official Support Policy. However, it’s important to note that upgrading all projects immediately is not necessary. Laravel 10 will continue to receive bug fixes until August 6th, 2024, and security fixes until February 4th, 2025.

2. PHP 8.1 Support Dropped: Laravel 11 is expected to drop support for PHP 8.1. Instead, it will move forward with supporting PHP versions 8.2 and 8.3, which are expected to be released around the same time as Laravel 11. This decision allows Laravel to keep pace with the latest PHP technologies while leaving outdated versions behind.

3. Minimalistic Application Skeleton: Laravel 11 comes with a slimmer application skeleton, meaning less boilerplate code to deal with.

Several changes have been made to achieve this, including the removal of the $policies property in AuthServiceProvider, the removal of SendEmailVerificationNotification in EventServiceProvider, and the removal of BroadcastServiceProvider. Auto-event discovery is now enabled by default, and several middlewares have been removed from the skeleton.

For example, the removal of the $policies property in AuthServiceProvider might look like this:

Before:

protected $policies = [
    'App\Model' => 'App\Policies\ModelPolicy',
];

After:

// $policies property removed

4. Dumpable Concern: Laravel 11 introduces a new Dumpable trait, intended to replace the current dd and dump methods in most of Laravel’s classes. This trait allows Laravel users and package authors to include debugging methods easily within their classes.

The new Dumpable trait can be used in your classes like this:

use Illuminate\Support\Dumpable;

class YourClass
{
    use Dumpable;

   // Your code...
}

5. New Model::casts() Method: Laravel 11 introduces a new way to define your casting through a casts() method in your model. This gives you a chance to use static methods from the class doing the casting. You can now also specify your casts as an array.

The new way to define your casting through a casts() method in your model might look like this:

public function casts(): array
{
    return [
      'created_at' => 'datetime:Y-m-d',
      'updated_at' => 'datetime:Y-m-d H:i:s',
    ];
}

6. Installation: Laravel 11 can be installed using the Laravel installer with the –dev flag, which installs the master branch from the laravel/laravel repository. Alternatively, Composer can be used for installation.

Laravel 11 can be installed using the Laravel installer or Composer. Here’s how you might do it with the Laravel installer:

laravel new example-app --dev

Sign up for free tutorials in your inbox.

We don’t spam! Read our privacy policy for more info.

Leave a Comment

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