Introduction:
Laravel is one of the most popular PHP frameworks and comes with many exceptional features. It is widely used to develop highly engaging and high-performance web apps. Laravel 9 was the latest update till now. Laravel 10 will be coming out in a month. It is the talk of the town. Everyone, especially PHP developers and Laravel developers, is keen to discover what's new in Laravel 10. It is time to douse this curiosity.
Laravel 10: An Overview of the Latest Version
Here is the first set of updates for Laravel 10
1. No support for PHP 8.0
This is an essential update for all the laravel developers and php developers. In this upcoming release, the support for PHP 8 will be dropped. Instead, Laravel will support PHP 8.1 and higher versions. So, all the laravel applications need to be upgraded to a minimum PHP 8.1 version. However, there is no need to panic as the version is yet to be released. Organizations with ongoing development can plan the move and gradually upgrade to laravel 10. Organizations can connect PHP development services to understand the impact of this change on their application and get the required changes done.
2. Native-type declarations from Laravel 10
From Laravel 10, you are going to witness the native type declarations with return types and type hints. It is time to move over the doc blocks. So, Laravel developers can now bring in the PHP type-hinting features to the Laravel projects without disturbing the compatibility at the framework level. At the same time, some redundant annotations have been removed. Another change is the addition of generic type annotations which is going to have a positive impact on the generics-supported coding as well as the autocompletion.
To understand this implementation let us take up the 'schedule()' method that you find in the app/console/Kernel.php. It will look somewhere like this:
* Define the application's command schedule.
- *
- * @param IlluminateConsoleSchedulingSchedule $schedule
- * @return void
*/
- protected function schedule($schedule)
+ protected function schedule(Schedule $schedule): void
Source url: Laravel 10: release date and new features (benjamincrozat.com)
3. Invokable validation rules are set at default
Laravel developers can easily identify this change. In Laravel 9, they had to set the '—invokable' flag to generate the invokable validation rules. Here is the code as an invokable validation rule sample.
use IlluminateContractsValidationInvokableRule;
class Uppercase implements InvokableRule
{
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param Closure(string): IlluminateTranslationPotentiallyTranslatedString $fail
* @return void
*/
public function __invoke($attribute, $value, $fail)
{
if (strtoupper($value) !== $value) {
$fail('The :attribute must be uppercase.');
}
}
}
Source: Laravel 10: release date and new features (benjamincrozat.com)
These invokable validation rules are now default in Laravel 10. The code given below can be used as a sample to understand how the laravel developers will be creating new validation rule via artisan in Laravel 10.
# 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
source: A Look at What's Coming to Laravel 10 | Laravel News (laravel-news.com)
4. Laravel 9 deprecations
Many properties and methods had been deprecated in Laravel 9. As a next step, this deprecated lot has been removed in Laravel 10. Organizations can hire dedicated Laravel developers to understand these changes and accordingly upgrade their Laravel applications. All the Laravel applications need to be tested against these changes while moving to Laravel 10. Some of the deprecated methods that have been removed are:
- Route::Home method
- assertTimesSent
- dates property
These are the major changes that you will come across in Laravel 10.
Conclusion
Upgrading to Laravel 10 can be tedious for any organization. They would need to back up the current version of the application, test the app against the changes, update the required extensions and technical things, install Laravel and finally complete the upgrade with the up-and-running application. If you have an idea of what needs to be done then you can hire a dedicated Laravel developers. It would be a great idea to Hire a Laravel Development Company that can analyze the current application, find out the required changes, and implement it successfully.
Experts will use best practices and tools to upgrade the application. At the same time, they can equip the development and maintenance team with the required technical knowledge. The release of Laravel 10 is just a month away and more new features will be announced. It would be best to hire Laravel development experts today to get the required updates at the earliest without any glitches in the application performance.
About Author
Subscribe to Our Newsletter!
Join us to stay updated with our latest blog updates, marketing tips, service tips, trends, news and announcements!