Today, the Laravel community was thrilled to announce the release of Laravel 10. This new version brings improvements over the previous Laravel 9 release by introducing argument and return types to all application skeleton methods, as well as all stub files used to generate classes throughout the framework. Additionally, a developer-friendly abstraction layer has been introduced to simplify starting and interacting with external processes.
The Process facade has been introduced in Laravel 10 to simplify starting and interacting with external processes. With the Process facade, you can easily run and manage concurrent processes, and even fake processes for convenient testing.
use Illuminate\Support\Facades\Process; $result = Process::run('ls -la'); $result->successful(); $result->failed(); $result->exitCode(); $result->output(); $result->errorOutput(); $result->throw(); $result->throwIf($condition);
Native Type Declarations to the Application Skeleton
Laravel 10 is introducing native type declarations in the application skeleton code. This means that type-hints and return types will be added to userland code generated by the framework. This article will explore the benefits of this approach, and why it's a great step forward for Laravel projects.
The type-hinting is being added in a way that maintains backward compatibility at the framework level while bringing the latest PHP type-hinting features to Laravel:
- Return types
- Method arguments
- Removal of redundant annotations where possible
- Support for userland types in closure arguments
- No typed properties
Invokable Validation Rules as Default
Laravel 10, invokable validation rules are now the default. This means that when creating a new validation rule using Artisan, it will be invokable by default. In Laravel 9, creating an invokable validation rule required a flag, but in Laravel 10 it's simply done with:
# Laravel 9 artisan make:rule Uppercase --invokable artisan make:rule Uppercase --invokable --implicit # Laravel 10 artisan make:rule Uppercase artisan make:rule Uppercase --implicit
Profile Option for Tests
Laravel 10 is also introducing a --profile option for tests, which makes it easy to identify slow tests in your application. This option should help keep your tests running quickly and efficiently, and make it easier to either fix slow tests or group them to reduce their impact on your test suite.
New String Password Helper
Laravel 10 also includes a new Str::password method that can generate a secure, random password of a specified length. The password will consist of a combination of letters, numbers, symbols, and spaces, and by default it will be 32 characters long. For example:
use Illuminate\Support\Str; $password = Str::password(); // Output: 'EbJo2vE-AS:U,$%_gkrV4n,q~1xy/-_4' $password = Str::password(12); // Output: 'qwuar>#V|i]N'
Another exciting addition in Laravel 10.x is the release of the first-party package Laravel Pennant. This package provides a light-weight and streamlined approach to managing feature flags in your application. Out of the box, it includes drivers for in-memory arrays and databases for storing feature flags. You can easily define features using the
Feature::define method and determine if a user has access to a given feature using the
Feature::active method. Laravel Pennant also includes Blade directives for convenient use in your views.
For more information on Laravel 10 and its new features, developers can check the official releases page for updated information as it becomes available.
Happy coding! 😇