Hey developers, we're thrilled to announce the release of Laravel v10.0! With this latest version, they have continued to make improvements to the framework by adding argument and return types to all application skeleton methods and stub files used to generate classes. Additionally, they have introduced a developer-friendly abstraction layer for starting and interacting with external processes, and they also added Laravel Pennant to make managing your application's feature flags even easier.
If you're eager to get all the juicy details about this release, check out our official release notes and upgrade guide. We'll also cover some of the highlights below.
Method Signature + Return Types
When Laravel was first released, it utilized all the type-hinting features available in PHP at the time. However, over the years, many new features have been added to PHP, including additional primitive type-hints, return types, and union types. With Laravel 10.x, we have updated the application skeleton and all stubs used by the framework to introduce argument and return types to all method signatures. This change is entirely backwards compatible with existing applications, so don't worry if you don't have these type-hints yet, your existing applications will continue to function normally.
<?php
namespace App\Http\Controllers;
use App\Models\Flight;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class FlightController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): Response
{
//
}
/**
* Display the specified resource.
*/
public function show(Flight $flight): Response
{
//
}
// ...
}
Laravel Pennant
Laravel Pennant is a new first-party package that we've released to make managing your application's feature flags even easier. It offers a lightweight, streamlined approach to feature flag management, and it comes with an in-memory array driver and a database driver for persistent feature storage. Defining features is now easier than ever with the Feature::define method.
use Laravel\Pennant\Feature;
use Illuminate\Support\Lottery;
Feature::define('new-onboarding-flow', function () {
return Lottery::odds(1, 10);
});
if (Feature::active('new-onboarding-flow')) {
// ...
}
Plus, checking if the current user has access to a feature is as easy as using the @feature Blade directive.
@feature('new-onboarding-flow')
<div>
<!-- ... -->
</div>
@endfeature
Processes
Laravel 10.x also introduces a beautiful abstraction layer for starting and interacting with external processes. With the new Process facade, you can start and manage concurrent processes with ease.
use Illuminate\Support\Facades\Process;
$result = Process::run('ls -la');
return $result->output();
You can even fake processes for convenient testing. If you want to learn more about interacting with processes, check out the comprehensive process documentation.
Process::fake();
// ...
Process::assertRan('ls -la');
Processes may even be started in pools, allowing for the convenient execution and management of concurrent processes:
use Illuminate\Process\Pool;
use Illuminate\Support\Facades\Pool;
[$first, $second, $third] = Process::concurrently(function (Pool $pool) {
$pool->command('cat first.txt');
$pool->command('cat second.txt');
$pool->command('cat third.txt');
});
return $first->output();
Horizon / Telescope Facelift
Horizon and Telescope have a fresh, modern look with improved typography, spacing, and design.
We hope you're excited about these new features and improvements in Laravel 10. Happy coding!