Laravel is one of the most powerful web frameworks and with the release of version 10 it has received some very welcome new features. The most interesting new additions are the new process interaction layer and first party feature flag support. Not to be excluded, Laravel’s testing support has been upgraded, letting you profile your tests and identify problem areas.
Laravel Pennant
Pennant is a new first party offering from the Laravel team that provides a well built and tested interface for feature flags. Feature flags have lots of uses including AB testing, rolling out features incrementally, and trunk-based development strategies. Pennant makes it easy and safe to explore and use these development methods.
Feature::define('new-onboarding-flow', function () {
return Lottery::odds(1, 10);
});Defining a feature is as simple calling the Feature::define method and providing a name and closure which returns whether or not the feature should be defined as enabled. The closure receives the “scope” of the feature check which is most commonly the currently authenticated user, and this can be changed. The can be used to check if the feature should be defined or not, as shown below:
Feature::define('the-best-feature', fn (User $user) => match (true) {
$user->isInternalTeamMember() => true,
$user->isHighTrafficCustomer() => false,
default => Lottery::odds(1 / 100),
});This functionality is a great way to implement AB testing!
It’s just as simple to check if a feature is enabled as it is to define one. It can be done simply through the Feature::active method as shown below:
return Feature::active('the-best-feature')
? $this->resolveNewApiResponse($request)
: $this->resolveLegacyApiResponse($request);Pennant also provides a convenient blade directive through @feature(<feature>) to check if a feature has been defined.

Process Abstraction
Laravel 10 provides a new way to interact with processes. The new Process facade offers a more convenient way to launch and interact with processes outside of your application. The new facade offers many useful features including timeouts, pooling, and easy access to outputs.
Starting a new process is as simple as using Process::run and passing the name of the required process. The run method executes a process and will wait until the command is finished until proceeding. The start method on the other hand launches an asynchronous method. We will focus on the former.
The results of a process can be accessed easily by calling the output method on the process instance.
$result = Process::run('ls -la');
$output = $result->output();To ensure you don’t end up with an endlessly running process blocking your application, an exception is thrown after 60 seconds if the process is still running. This timeout can be customised with the timeout method. Alternatively, you can allow the process to run endlessly with the forever method. idleTimeout allows you to stop the process earlier when its not responding.
$process1 = Process::forever()->run('bash import.sh');
$process2 = Process::timeout(60)->idleTimeout(30)->run('bash import.sh');You can also run many processes at the time using a process pool
$pool = Process::pool(function (Pool $pool) {
$pool->path(__DIR__)->command('bash import-1.sh');
$pool->path(__DIR__)->command('ls -l');
$pool->path(__DIR__)->command('cat shoppingList.txt');
})->start(function (string $type, string $output, int $key) {
// ...
});You wait for each process to finish with $pool->wait() and then access the the results of each process.
The Facade also allows you to fake processes making testing easy.
Test Profiling
Through the new --profile option Laravel 10 can now tell you which tests are taking the longest. This will be displayed in the CLI. Although we expect some tests to take longer than others, knowing the real numbers can help find unexpected problems. This can then start a more thorough investigation into the issue.
This new feature can be accessed as follows:
php artisan test --profileFurthermore, you can have Laravel create scaffolding for the Pest testing framework when creating a new Laravel project. Simply add the --pest option to the laravel new command to see this in action. Pest offers a cleaner interface for testing. Learn more about testing with Pest and Laravel here.
Artisan Make Improvements
The Artisan console is a very helpful tool for doing just about anything Laravel. One of its most useful features is the generator make commands. These commands make it simple to make anything from a Controller to an Observer. The generator commands have received an upgrade with Laravel 10, they no longer require any input. Instead, now they will prompt you for any of the required inputs.
I can’t welcome this change enough, as I’m sure every Laravel user has been frustrated with the seemingly inconsistent behaviour regarding these inputs in the past. I am also looking forward to getting to work more with Pennant, and seeing how it can act as another layer of protection against mismatched frontend and backend readiness. I’m not sure if i’ll find a place to work the new process abstraction into, but I’m sure i’ll be thankful it exists if I ever need to deal with external processes.
What do you think about Laravel 10’s new features? Are they something that will improve your project and workflow, or should this release have focused on something else?
We develop several applications in Laravel at Espirito & FONSEKA. As one of the pioneers of using Laravel in Australia, we are excited to bring these new improvements to our stable of softwares.
Find us at FONSEKA.
Resources:
