Migration Scripts
March 22, 2023The Beauty Of Writing Clean Code: Why Refactoring And Optimising Is Essential
April 3, 2023Introduction
Laravel is one of the most popular and widely used PHP web frameworks, known for its elegant, and expressive syntax, with a robust set of out of the box features. With each new release, Laravel expands its features and make further improvements, making it a great choice for developers looking to build modern web applications. Laravel 10 is the latest major release of the framework, and it comes with some significant changes.
PHP 8.1.0 Required
One of the most significant changes in Laravel 10 is that it now requires PHP 8.1.0
or greater. This means that if you're still using an older version of PHP, you'll need to upgrade before upgrading to Laravel 10.
Composer 2.2.0 Required
Laravel 10 now requires a minimum Composer version of 2.2.0
in addition to requiring PHP 8.1.0
or above. This ensures that you're using the latest version of Composer, which provides better performance and stability.
Native Type Declarations in Laravel 10 Skeleton
Laravel 10 includes native type declarations in the application skeleton code. This means that any code generated by the framework will have type-hints and return types. This can make the code more readable and easier to maintain, and it brings the latest PHP type-hinting features to the Laravel framework without breaking backward compatibility at the framework level.
Invocable Validation Rules are the Default
From Laravel 10, when you create a new validation rule via artisan, it will be an invocable rule by default. This is to simplify the validation code and make it easier to read and maintain.
Process Layer for Laravel
The Laravel Process service brings the Laravel developer experience to running CLI processes. It includes rich features out of the box, such as 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 the fake()
function, and preventing stray processes during tests.
Profile Option for Tests
A new feature coming to Laravel 10 is a --profile option that will make it easy for you to identifying any slow tests in your application. This can help keep your tests fast and help you either fix the slow tests or to better group them to make it easier not to run them all the time.
Laravel Pennant
The Laravel team has introduced a package called "Laravel Pennant" with the release of Laravel 10, which offers feature flags for applications. Feature flags, also known as feature toggles, allow for gradual feature roll-outs, A/B testing of new features or UI modifications, aligns well with Continuous Deployment work-flows, and the ability to disable features in the event of an incident.
New String Password Helper
Laravel 10 includes a new String Password helper, which can generate a secure, random password of a given length. The password will consist of a combination of letters, numbers, symbols, and spaces, and by default, passwords are 32 characters long.
Upgrading to Laravel 10
If you're upgrading to Laravel 10, you'll need to update your dependencies, including Laravel framework ^10.0
, Sanctum to ^3.2
, DBAL to ^3.0
, Ignition to ^2.0
, and Passport to ^3.2
. If you have to Sanctum 3.x
from the 2.x
release series, you should consult the Sanctum upgrade guide. Additionally, if you wish to use PHPUnit 10, you should delete the processUncoveredFiles
attribute from the coverage
section in your phpunit.xml
configuration file.
Laravel 10 is a significant release that brings exciting new features and improvements to the framework