Articles | Digital Delivery

Laravel 10: What's New and Improved

3 min read

Laravel 10 is the latest version of the popular PHP web application framework. It comes with several new features and improvements that make it more powerful and efficient than ever before. In this article, we will explore the new features and enhancements of Laravel 10 and provide code snippets to demonstrate their usage.

Laravel 10 drops support for PHP 8.0

Laravel framework will drop support for PHP <=v8.0 in Laravel 10. The minimum required version is PHP ^8.1. we can expect to see 8.1 features used in the framework, such as readonly properties.


Laravel Pennant

Laravel Pennant is a package created by the Laravel team that will arrive with Laravel 10 and provides Feature Flags for your applications.

This package is a simple and lightweight feature flag package - without the cruft. Feature flags enable you to incrementally roll out new application features with confidence, A/B test new interface designs, compliment a trunk-based development strategy, and much more.


Process layer for Laravel

Working with testing and running CLI processes is made easy and efficient with the Laravel Process service.

use Illuminate\Support\Facades\Process;
$result = Process::run('ls -la');

Out of the box, the Process layer boasts a variety of rich features, including:

  • Fluent process methods to build a process instance before running it
  • Process output handling as it is received
  • Asynchronous processes
  • Process Pools
  • Rich testing features via `fake()`
  • Preventing stray processes during tests

Never before has testing processes been so effortless.


Invokable Validation rules are the default

With Laravel 10, invokable validation rules have become the default. Creating a new validation rule through artisan will now yield the following result:

# Laravel 9 creates a rule class that implements the
# Illuminate\Contracts\Validation\Rule interface
artisan make:rule Uppercase
# Laravel 9 flag to create an invokable and implicit rule
artisan make:rule Uppercase --invokable
artisan make:rule Uppercase --invokable --implicit
# Laravel 10 creates an invokable rule by default
artisan make:rule Uppercase
# Laravel 10 implicit rule
artisan make:rule Uppercase --implicit


Native type declarations in Laravel 10 skeleton

The latest version of Laravel 10, will come equipped with native type declarations in the application skeleton code. This feature comes with some considerations, which we delve into in our article. Overall, we believe you will appreciate the enhanced type hints when building new projects with Laravel.

The latest PHP type-hinting features are being incorporated into Laravel projects in a manner that ensures backward compatibility at the framework level.

  • Return types
  • Method arguments
  • Redundant annotations are removed where possible
  • Allow user land types in closure arguments
  • Does not include typed properties


Profile option for tests

A new feature coming to Laravel 10 is a `--profile` option that will make it easy for you to find any slow tests in your application.

By utilizing the `--profile` option, you can optimize the speed of your tests and streamline the process of identifying and troubleshooting slow tests, or grouping them more efficiently to avoid unnecessary test runs.


New String Password helper

With the `Str::password` method, generating a secure, randomized password of any desired length is made simple. The password will be a combination of letters, numbers, symbols, and spaces. The default length for passwords is 32 characters.

use Illuminate\Support\Str;
$password = Str::password();
// 'EbJo2vE-AS:U,$%_gkrV4n,q~1xy/-_4'
$password = Str::password(12);
// 'qwuar>#V|i]N'


And More...

To stay up-to-date with the latest information, it's recommended to periodically check the official releases page for any updates as they become available.