2078

Laravel 10 Released - Release notes, new features, and deprecations!

By: Skynet Technologies USA LLC
8 mins
500
Laravel version 10

The major version Laravel 10 was released on February 14th, 2023. Previous versions of Laravel have set a bar and that is the reason, Laravel’s users have huge expectations from the upcoming version.

Before Laravel 9, Laravel used to release its major versions every six months. However, now they have transitioned that old practice to yearly releases post-Laravel 8 release. The idea behind this significant change was to reduce the maintenance burden on community and development teams and release new versions with more robust features.

There will be many changes coming with this new version of Laravel PHP framework and several new additions must have happened. Though the release has still a few months’ time, you must know what will be new with Laravel 10 and how you need to prepare for it. Without breaking backward compatibility, the new versions now come with more sturdy and relevant features, which we’ve seen in Laravel 9. And now Laravel 10.0 is continuing with the same concept of backward compatibility. It has improvements that were made in the previous minor version of Laravel 9.x by introducing argument and return types to all application skeleton methods and stub files used to generate classes across the framework.

We’ve tried curating important updates about the Laravel version 10. Read the article to see what is new in Laravel 10.

Laravel 10: New Features

1. Laravel 10 is not supporting PHP 8.0

With this version of Laravel, you will not find PHP <= version 8.0. Now the minimum requirement is PHP 8.1 for Laravel 10. Thus, you can expect PHP 8.1 features used in the Laravel framework, for example, read-only properties.

YOU MAY ALSO LIKE: PHP 8.2 Improvement and Deprecations

2. Native type declarations in Laravel 10 skeleton

The Application Skeleton Code will have Native type declaration in Laravel 10. It implies any code in userland generated by the framework will have type-hints and return types. The new types will be added advantages for new project creations.

The types are being added in the framework thoughtfully so that they bring the latest PHP type-hinting features to the Laravel projects and that too without breaking backward compatibility. Some of the features are:

  • Return types
  • Method arguments
  • Redundant annotations are removed where possible
  • Allow user land types in closure arguments
  • Does not include typed properties

3. Invokable validation rules are by default in Laravel 10

Now in Laravel 10, you will find invokable validation rules are default and when you create a new validation rule through artisan, it will look like this:

# Laravel 9 creates a rule class that implements the
#Illuminate\Contracts\Validation\Rule interface
artisan make:rule Uppercase
# Laravel 9 flag to create an invokable and implicit rule
artisan make:rule Uppercase --invokable
artisan make:rule Uppercase –invokable --implicit
#Laravel 10 creates an invokable rule by default
artisan make:rule Uppercase
#Laravel 10 implicit rule
Artisan make:rule Uppercase –implicit 

4. Laravel 10 dropped support for Predis version 1

If your project is using the Predis version 1, you have to upgrade it to version 2 now.

Or else, instead of using Predis, you can consider using PHP’s native Redis extension. This extension is faster, which will boost the speed of your website when the traffic is maximum.

5. dispatchNow() has been removed from Laravel 10

Laravel had a popular method, which is dispatchNow(). This method was deprecated in Laravel 9 in favour of dispatchSync() and now it has been removed in Laravel 10. So, you should now remove it from all your projects.

6. Laravel Pennant

Laravel 10.0 has come up with one new first-party package, which is known as Laravel Pennant. It is a well-organized and lightweight approach to managing an application’s feature flags. Laravel Pennant includes an in-memory array driver and a database driver for long-lasting feature storage.

All the features can be defined through Feature::define method:

use Laravel\Pennant\Feature;
use Illuminate\Support\Lottery;

Feature::define(‘new-onboarding-flow’, function () {
  Return Lottery::odds(1,10);
});

Once you will define a feature, you can understand if the current user has access to the given features:

If (Features::active(‘new-onboarding-flow’)) {
  // …
}

Blade directives are also available to make the process convenient:

@feature(‘new-onboarding-flow’)
<div>
  <!-- … -->
</div>
@endfeature

Laravel Pennant has a wide range of modern APIs and advanced features that makes the latest version more useful.

7. Process Interaction

To start and interact with external processes, Laravel 10.0 comes along with a new attractive abstraction layer, which is a new Process façade

use Illuminate\Support\Facades\Process;
$result = Process::run(‘Is -Ia’);
return $result->output();

For convenient execution and management of coinciding processes, processes can be started in pools as well –

use Illuminate\Process\Pool;
use Illuminate\Support\Facades\Process;

[$first, $second, $third] = Process::concurrently(function (Pool $pool) {
  $pool->command(‘cat first.txt’);
  $pool->command(‘cat second.txt’);
  $pool->command(‘cat third.txt’);
});

return $first->output();

Processes can be faked as well for convenient testing –

Process::fake();
// …
Process::assertRan(‘Is -Ia’);

8. Pest Scaffolding

Using Laravel 10.0, you can be able to create new Laravel projects with default Pest test scaffolding. To use the feature, you only have to provide --pest flag while creating the new application using the Laravel installer –

laravel new example-application --pest

9. Generator CLI Prompts

Now Laravel’s in-built make commands don’t ask for input. This is a new feature to improve the overall framework’s experience for developers. If the commands are given without inputs, then you will be prompted for required arguments –

php artisan make:controller

10. Horizon and Telescope Makeover

Laravel packages Horizon and Telescope get an updated and fresh look with modern and improved spacing, design, and typography.

How will you install Laravel 10?

It is simple, Laravel installer has a dev flag that installs the master branch from the Laravel repository.

laravel new hello-world—dev

If you wish to use Composer, then

composer create-project—prefer-dist laravel/laravel laravel-dev dev-master

Important things to remember!

1. Versioning Scheme

Semantic Versioning is followed by Laravel and its first-party packages. We know that now its major versions are released yearly whereas minor versions and patch releases keep coming every now and then. However, they don’t contain breaking changes. They (breaking changes) are included in all major releases.

Please note that Named arguments are not included in Laravel’s backward compatibility guidelines. Nevertheless, to improve the Laravel codebase, you can rename function arguments. Thus, while calling Laravel methods, using named arguments must be done very carefully and you should know that the parameter names may change in the future.

2. Support Policy

Laravel offers bug fixes for 18 months and security fixes for 2 years for every released version. And for all additional libraries (including Lumen), only the latest major release gets bug fixes.

Laravel 9 (released in February 2022) will get its bug fixes by August 2023 and security fixes by February 2024.

Similarly, Laravel 10 (which released in February 2023) will receive bug fixes until August 2024 and security fixes until February 2025.

And you can assume the same pattern for the next major release of Laravel, which is Laravel 11.

Deprecations in Laravel 9 and removal from Laravel 10

Whichever method is marked as deprecated in Laravel 9 is removed from Laravel 10. The release upgrade guide of Laravel 10 outline all the deprecated methods, potential impact assessment, and upgrade guidelines.

Here are a few deprecations found in the comparison of the Laravel framework’s master branch and 9.x branch:

Remove various deprecations Pull Request #41136
Remove deprecated dates property in Pull Request #42587
Remove handleDeprecation method in Pull Request #42590
Remove deprecated assertTimesSent method Pull Request #42592
Remove deprecated ScheduleListCommand’s $defaultName property 419471e
Remove deprecated Route::home method Pull Request #42614
Remove deprecated dispatchNow functionality Pull Request #42591

Do you know, you can contribute to Laravel 10?

All the new updates for Laravel 10 you can see on GitHub.

The pull requests will let you know what is already been done in the new version. If you are facing any pain point with the framework, you are allowed to create its solution.

Send the PR over to the laravel/framework repository, collect feedback, improve, and get merged.

Please note, your solution will get merged only if it is out-of-the-box and practical to manage.

Wrapping up

Laravel is an impressive framework with cleaner and simpler syntax. It has ample web development packages that assist developers with quick and impeccable web application development. And Laravel 10 is another exceptional version that eases common application development tasks in web projects. It is a breeze for developers to create new projects using Laravel 10.

For existing applications, if you have not updated to Laravel 10, it is highly recommended to read the release notes and update your application.

Skynet Technologies provide custom Laravel development services such as Laravel enterprise solution, Restful App development, Laravel upgrades, Laravel migration, and more suitable for small to large scale business across all the industries.

Not limited to this, we are acknowledged as an official Bagisto solution partner. Bagisto is one of the Laravel ecommerce package to build and scale your business! We provide end-to-end Bagisto Development services to make your store stand out from your competitors.

We are recognized as an international partner of Aimeos, a Laravel ecommerce package owing to the unparalleled expertise shown in the delivery of e-commerce websites. We assist our clients in developing a cost-effective, well-supported, and fully functional e-commerce store with Aimeos ecommerce services!

You can hire experienced Laravel developers or contact at [email protected]. Fill out form below to request a free quote.

Source: https://laravel-news.com/laravel-10