Laravel 10 has arrived and it comes with a host of exciting new features and updates. Here’s a rundown of the most notable ones:
PHP 8.1 – The Engine Behind Laravel 10
Laravel 10 has a minimum requirement of PHP 8.1, and it’s expected to leverage some of the latest PHP 8.1 features such as readonly properties and array_is_list.
Support for PHP 8.2
Laravel 10 is compatible with PHP 8.2, which was released in December 2022. The entire Laravel ecosystem, including Forge, Vapor, and Envoyer, is ready for PHP 8.2. You can even use PHP 8.2 with Laravel 9, giving you more versatility and choice.
Upgraded Laravel Starter Kits
Laravel Breeze and Jetstream will be available for use with Laravel 10 once it’s released. These starter kits have been upgraded to Inertiajs 1 and Jetstream now includes complete dark-mode support.
Enhanced Predis Version
Predis is a powerful Redis client for PHP that helps you optimize caching to improve the user experience. Laravel 10 will no longer support Predis 1, and it now only supports Predis 2. While Predis is still the recommended package for interacting with Redis, you can also use the official PHP extension that provides an API for communicating with Redis servers.
Improved Type Declarations
Laravel 10 introduces native type declarations to provide better clarity in code. This replaces the use of DocBlocks and makes it easier for developers to understand what a piece of code does and what inputs and outputs are expected. As a result, IDEs will be able to provide more robust auto-complete features.
Default Invokable Validation Rules
In Laravel 9, invokable validation rules required the use of the –invokable flag after the artisan command. This is no longer necessary in Laravel 10, as all validation rules are invokable by default. Simply run the following command to create a new invokable rule:
php artisan make:rule CustomRule
Native Column Modification Support
Laravel 10 introduces a new feature that eliminates the need for the doctrine/dbal package when using the change() method to modify columns. This feature allows developers to modify columns on MySQL, PostgreSQL, and SQL Server without the need for additional packages. Note that this is a significant and breaking change, so make sure to add all attributes when changing the type of a column. If you’re using multiple database connections, it’s recommended to use the Schema::useNativeSchemaOperationsIfPossible() method in App\Providers\AppServiceProvider to take advantage of native schema operations.
We hope this gives you a good idea of the new features and upgrades in Laravel 10. Happy coding!