Laravel 10 Released: A Game-Changing Update for Web Developers
Laravel 10 is released on 14 February 2023. It comes with various new features and improvements to existing functionality, which makes building scalable, secure, and high-quality applications easier than ever before. Whether you’re a Laravel developer or just starting, It is worth checking out.
Starting from now, Laravel will have one major release every year, with the following schedule:
- Laravel 9: released on February 8th, 2022.
- Laravel 10: released on February 14th, 2023.
- Laravel 11: to be released in the first quarter of 2024.
Now Laravel 10 doesn’t support PHP 8.0
The framework will no longer provide support for PHP versions less than 8.0. The minimum PHP version required to run Laravel 10 will be PHP 8.1 or higher.
Application skeleton code
The Laravel application skeleton code will include native-type declarations. This means that any user-generated code will have type hints and return types. We believe this change will be beneficial for new projects and make development more efficient.
To ensure backward compatibility at the framework level, it will implement PHP’s latest type-hinting features in a non-disruptive manner. The following changes will be introduced:
- Return types will be supported.
- Method arguments will be type-hinted.
- Redundant annotations will be removed where possible.
- User-defined types will be allowed in closure arguments.
- Typed properties will not be included.
String Password Helper
You can use the Str::password
method in Laravel to create a random, secure password of a specified length. The generated password will contain a mixture of letters, numbers, symbols, and spaces. By default, the length of the password is set to 32 characters.
To use the Str::password
method, you need to include the Illuminate\Support\Str
class in your code. Here are some examples of how to generate a password:
use Illuminate\Support\Str;
// Generate a 32-character password
$password = Str::password();
// Example output: 'EbJo2vE-AS:U,$%_gkrV4n,q~1xy/-_4'
// Generate a 12-character password
$password = Str::password(12);
// Example output: 'qwuar>#V|i]N'
Deprecations from Laravel 9
Laravel 10 removes some of the methods and functionalities marked as deprecated in Laravel 9. Here are some of the deprecations that have been identified by comparing the Laravel framework’s master branch to the 9. x branch:
- Pull Request #41136: removing various deprecations.
- Pull Request #42587: removing the deprecated
dates
property. - Pull Request #42590: removing the
handleDeprecation
method. - Pull Request #42592: removing the deprecated
assertTimesSent
method. - 419471e: removing the deprecated
$defaultName
property inScheduleListCommand
. - Pull Request #42614: removing the deprecated
Route::home
method. - Pull Request #42591: removing the deprecated
dispatchNow
functionality.
Invokable Validation rules are the default
If you create a new validation rule via artisan in Laravel 10, you should expect invokable validation rules to be set as the default option.
# 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
How to upgrade from Laravel 9 to Laravel 10
If you’re looking to upgrade your Laravel application from version 9 to version 10, the good news is that it can be done easily with Laravel 10.x Shift. This tool is designed to automate the upgrade process and can save you up to two hours of valuable time. It’s worth noting that both Laravel and Laravel 10.x Shift will receive regular updates, and you can request a rerun if necessary.
Before you upgrade, there are a couple of essential requirements that you should be aware of. Firstly, your current Laravel application must be running on version 9 or a more recent version. Secondly, your server needs to have PHP 8.1 or a higher version installed to support Laravel 10.
In the end
Overall, Laravel 10 is a significant step forward for the popular PHP framework, with several important improvements that make it easier than ever to build high-quality, robust web applications. If you need support or have any questions, please feel free to contact us here