Laravel v10 Released

We're excited to announce the release of Laravel 10.0! Building on the enhancements introduced in Laravel 9, version 10.0 brings argument and return types to all application skeleton methods, as well as the stub files used to generate classes across the framework. Additionally, a new, developer-friendly abstraction layer has been added for starting and interacting with external processes. Plus, with the introduction of Laravel Pennant, managing feature flags for your application has never been easier. Check out our official release notes and upgrade guide for a comprehensive breakdown of the latest features and improvements. Here are some of the key highlights: Method Signature and Return Types When Laravel was first released, it made use of all the type-hinting features available in PHP at the time. However, since then, PHP has seen numerous updates, including additional primitive type-hints, return types, and union types. Laravel 10.x takes advantage of these updates by introducing argument and return types to all method signatures in the application skeleton and all stubs utilized by the framework. Additionally, redundant "doc block" type-hint information has been removed.



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
    {
        //
    }

    // ...

}
This update is fully backwards compatible with current applications, which means that applications that don't already use these type-hints will continue to work as expected. Laravel Pennant Laravel has released a new first-party package called "Laravel Pennant". This package provides a simplified and efficient method for managing your application's feature flags. Out of the box, Pennant includes an in-memory array driver and a database driver for persistent feature storage. You can define features easily by using the Feature::define method.

use Laravel\Pennant\Feature;
use Illuminate\Support\Lottery;

Feature::define('new-onboarding-flow', function () {
    return Lottery::odds(1, 10);
});
After defining a feature, checking if the current user has access to it is straightforward:

if (Feature::active('new-onboarding-flow')) {
    // ...
}
For the sake of convenience, Blade directives are also at your disposal:

@feature('new-onboarding-flow')
    
@endfeature
Pennant offers a variety of more advanced features and APIs. For more information, please consult the comprehensive Pennant documentation. Processes Laravel 10.x introduces a beautiful abstraction layer for starting and interacting with external processes via a new Process facade:

use Illuminate\Support\Facades\Process;

$result = Process::run('ls -la');

return $result->output();
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();
In addition, processes may be faked for convenient testing:

Process::fake();

// ...

Process::assertRan('ls -la');

Comments

Popular posts from this blog

Laravel Model

Laravel Artisan: The Command-Line Interface for Your Laravel Application

Laravel Facades