Prior to the release of Laravel 9, every significant upgrade was issued every six months. However, the business recently revised its Laravel release cycle and now releases significant updates just once per year. Laravel 10 was ready for release on February 7, 2023, a year after Laravel 9 was released (on the 8th of February 2022).
The update, however, was actually released on February 14, 2023. Up until August 6, 2024, Laravel 10 bug patches will be accessible. Security updates will continue to be available until February 4, 2025.
Look at a couple of the main points of this update here:
With Laravel 10, PHP V8 support has been discontinued.
All of Laravel 9's deprecated methods have been removed in Laravel 10.
The app's skeleton code now uses native type declaration in Laravel 10
eager optimization of loading
the deletion of DispatchNow()
This is only a sneak peek at what to expect from this release; you can read more about the features and deprecations later.
Updates to Laravel 10 and New Feature
Everyone is curious to hear about the new features added in Laravel 10, whether they are developers or owners of businesses. As the website development company in Kochi, we have investigated what's new. Let’s check out:
Minimum supported PHP v8.1
As you are already aware, the Laravel framework is based on PHP. You may not be aware, though, that Laravel 10 requires PHP 8.1 as a minimum. Consequently, updating to PHP v8.1 would need upgrading to Laravel's most recent version 2022.
You may use PHP technologies like fsync(), fdatasync(), PureSection type, enumerations, and read-only properties,among others as now that Laravel 10 is available.
Support for PHP 8.2
The most recent version, PHP 8.2, was made available in December 2022. It has been around for such a short period, but Laravel 10 still supports it. Therefore, if you're eager to work with the most recent version of PHP, you may definitely do it with 10 Laravel.
DNF types, new ReadOnly classes, fetching enum properties in const expressions, and more intriguing new features are yours to use. Additionally, before 2025, the PHP 8.1 version is anticipated to reach the end of support.
Additionally, Laravel Forge, Vapour, Envoyer, and other Laravel ecosystem technologies are compatible with PHP 8.2. Therefore, using a stable PHP 8.2 version will provide you with the best results if you prepare carefully during development.
Native type declaration
Before this upgrade, the skeleton code for Laravel used DocBlocks to describe the code and the expected replies and parameters. However, DocBlocks are replaced with native-type declarations in Laravel 10.
As a result, the framework includes type clues and return types in every code it generates. The platform carefully incorporates these type-hints, which also provide backward compatibility. Some of the new declaration types in Laravel 10 are listed below:
Approach arguments
Return formats
Userland types are permitted in closure arguments.
deletion of pointless annotations
There are no typed properties included.
Therefore, the following should be used in place of the code below:
With this modification, IDEs will be able to more easily conduct features like auto-completion and function better by being able to identify the kind of argument and answer.
Invokable default validation rules
The 'invokable' flag has to be added in to build an invokable validation rule in Laravel prior to version 9. Let’s take a glance at the following code example:
Create a rule class
illuminate\Contracts\Validation\Rule interface
artisan make: rule uppercase
Flag to create an implicit and invokable rule
artisan make: rule Uppercase -- invokable
artisan make: rule Uppercase - invokable -implicit
The new functionality in Laravel 10 allows all Laravel validation rules to be invoked by default, so developers no longer need to include a flag. The following can be used as an alternative to establishing an invokable validation rule:
artisan make : rule customrule
Upgraded Laravel packages
The official Laravel packages have also been changed to work as efficiently as possible with the Laravel model. Recently updated are the following packages: the cashier stripe, Horizon, Passport, Valet, Breeze, Dusk, Pint, Scout, etc.
Native column modification is supported
Before this latest Laravel version, you had to rely on a separate package called DBAL (doctrine/dbal) in order to edit columns using the change() function. However, Laravel 10 fully removes this need.
In SQL Server, MySQL, and PostgreSQL, you can edit a column without using the DBAL package.
Eager loading optimization
The eager loading capability was included in Laravel to address the "N+1" problem caused by lazy loading, which requires a user to submit N+1 queries before receiving a response. The eager loading, however, also necessitated the execution of a large number of improbable requests.
As a result, Laravel nonetheless conducted these queries without the necessary data, even though no keys were to be loaded. This problem has been fixed in Laravel 10 since it now only executes database queries after checking for any available keys. There won't be a need for queries if there are no keys because it will provide an empty collection.
Laravel Pennant
The use of feature flags is like a boon for web apps that are constantly being updated and enhanced with new features. You will be able to enable and disable features using a feature flag as necessary. You can accomplish this without changing the application's source code or redeploying it.
Really fascinating, no?
Pennant is a package that Laravel 10 has provided for you so that you may manage your feature flags with ease. It has an in-memory array driver and a database. As a result, it is now simpler than ever to define a new feature and determine whether it is enabled or disabled.
Default pest scaffolding
Building a website's or application's framework is referred to as scaffolding. With Laravel 10, you can see that the test scaffolding is by default enabled whenever you build a new project. As a result, utilizing the Laravel installation just requires that you use the -pest flag as follows:
laravel new example-abc-app --pest
String password helper
With Laravel 10, a new security feature has been implemented that allows you to choose a random, extremely secure password of your choosing. You may achieve this by writing:
$password = Str::password(12);
Enhancement of Timebox class security
Because the Timebox class has been improved, your Laravel-built web application is now more resistant against timeless timing attacks. The class can now manage exceptions thrown during the execution of callbacks.
Supports PHPUnit 10
The PHPUnit 10 framework for unit testing was just published on February 3rd, 2023. Despite being the most recent release, PHPUnit 8 and 9 are still supported alongside Laravel 10's previous updates.
Database expressions
Since it was added only four days before Laravel 10's release, this feature was a last-minute addition. Working with numerous databases used to be extremely difficult.
For instance, you use PostgreSQL and MySQL as two databases. Now, you would have to create raw database code if you wanted to return the first non-null value of a list or table as an alias. And each time you comply with such a request, you will have to repeat the process.
However, you can only use these statements and expressions once when using new, reusable database expressions. Even while coding for database expressions may seem time-consuming to you, it is still preferable to repeatedly write raw database code.
Final Thoughts
Developers and business owners have been interested in Laravel ever since rumors of the newest version started to spread. The scope of the upgrades and additions, though, remained a mystery. Since Laravel 10 has been publicly launched, we can see that the core team has not only added a lot of new functionality but has also given attention to a lot of pull requests from members of the community.
You have a wide range of alternatives thanks to the update's expansion of support for several cutting-edge technologies. Rest assured that your development strategies will determine how best to use it. And for that, you might need to hire Laravel developers or website development companies in India who are knowledgeable about the industry.
Top comments (0)