Introducing Laravel 10: A Comprehensive Guide to Every New Feature and Change

Alex Stevens
Alex Stevens
...

Laravel is a powerful and flexible PHP web framework, has become increasingly popular in the web development world. With a rich set of tools and features, Laravel has made it easier for developers to build robust and scalable web applications. Now, with the release of Laravel 10, let's explore all the new features and changes it brings to the table.

Release Date

Laravel 10 was released on February 14, 2023, and is currently the latest version. However, it is not necessary to update all your projects immediately. Laravel 9 will receive bug fixes until August 23, 2023, and security fixes until February 6, 2024.

Long Term Support

Laravel 10 is not a Long Term Support (LTS) version. The framework's last LTS was version 6. However, each major version receives two years of bug and security fixes, providing enough time for developers to prepare their applications for an upgrade.

Installation

To install Laravel 10, you can use the official Laravel installer:

laravel new hello-world

Alternatively, you can use Composer explicitly:

composer create-project --prefer-dist laravel/laravel hello-world

Upgrading to Laravel 10 requires more than just following upgrade instructions. Before proceeding, consider carefully reviewing the upgrade guide. If you need more clarification, there is also a miracle solution available to automatize the process.

New Features and Changes

Laravel Pennant

Laravel Pennant is a first-party package that allows you to add feature flags to any Laravel 10 project. Feature flags enable you to enable or disable features at runtime without changing your code. For instance, you can deploy a feature only for a select set of users in your production environment, which is great for A/B testing.

To get started with Laravel Pennant, run the following command:

composer require laravel/pennant

You can define a feature and check if a user has access to it using the following code:

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')) {

// Do something

}

Laravel News has a step-by-step tutorial on Laravel Pennant.

External Processes

Laravel offers a comprehensive API for the Symfony Process component, making it easy to run external processes within your Laravel application. With Laravel's process functionality, developers can cater to the most frequent usage scenarios, resulting in an exceptional experience. You can even run processes concurrently.

To run a process, use the following code:

use Illuminate\Support\Facades\Process;

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

return $result->output();

For concurrent processes, use the following code:

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();

For more information on processes, refer to the official documentation.

Slow-Running Tests

The Artisan command php artisan test can now receive a --profile option, making it easy to identify slow-running tests. This command is provided by the package nunomaduro/collision in its 7th version.

Invokable Validation Rules

Starting from Laravel 10, invokable validation rules are the default. In Laravel 9, they could be generated using the --invokable flag with the php artisan make:rule command. With Laravel 10, you don't need to use that flag anymore, so the generated code is much simpler and easier to understand. This should mean that developers are less intimidated by the output.

Laravel v10 Bug Hunt: win $1K for fixing bugs

The Laravel team is encouraging developers to help find and fix bugs in Laravel v10 with the Laravel v10 Bug Hunt. The contest runs from February 14, 2023, to August 6, 2024, and offers a chance to win a $1,000 cash prize.

To participate, developers need to identify a bug in Laravel v10 and submit a pull request to fix it. The bug must be accepted and merged into the Laravel repository by August 6, 2024, to be eligible for the prize.

The Laravel team will select three winners based on the number and quality of their contributions. This is a great opportunity for developers to contribute to the Laravel community and improve their skills.

Conclusion

Laravel v10 brings several new features and changes that make it even more powerful and flexible than before. From feature flags and process handling to improved validation rules and native types, Laravel v10 has something for every developer.

Whether you're new to Laravel or a seasoned pro, there's never been a better time to start using Laravel v10. So take the time to explore its new features and see how they can improve your web development projects.

Alex Stevens
Alex Stevens

Latest Stories

Here’s what we've been up to recently.

Request a code sample

Certified Quality. Great Prices

We use cookies to improve your experience and to help us understand how you use our site. By using this site, you accept our use of cookies. Cookie Infox