Laravel 9 Released: What Should You Expect?
News February 10th 2022The newly released Laravel 9 is highly scalable and comes with so many new features, including a minimum PHP v8.0 version, controller route groups, a refreshed default Ignition error page, Laravel Scout database engine, Symfony mailer integration, Flysystem 3.x, Improved Eloquent accessors/mutators, and various other features.
Earlier, Laravel updates were released every 6th month. However, with the latest release of Laravel 9 in February 2022, the company has moved its framework to a 12-month major release cycle.
New Laravel 9 is the next long-term support version (LTS) and will receive bug fixes until February 2024 and security fixes until February 2025.
What is Laravel?
Laravel is an open-source PHP web application framework that is known for its elegant syntax. It includes an MVC framework that can be used to build simple to complex web applications using PHP programming language. It strictly adheres to the MVC (model-view-controller) architectural pattern.
Laravel also uses various community-driven packages as well as Symfony components to utilize several features within the framework.
New Features of Laravel 9
The new features and improvements that you can expect in the newly released Laravel 9 are –
Minimum PHP Requirement
First things first, Laravel requires the latest PHP 8 and PHPUnit 8 for testing. This is because Laravel 9 has the newest Symfony 6.0, which also operates on PHP 8.
PHP 8 has new features from the JIT compile to constructor property promotion.
Anonymous Stub Migration
When you run the popular migration command (given below), Laravel will make anonymous stub migration behavior.
php artisan make:migration
As the anonymous stub migration feature was released in Laravel 8.37 to fix the Github issues, the new Laravel 9 framework that too supports anonymous class migration files, will now set it up to default behavior.
New Query Builder Interface
The new Laravel 9 provides type hinting a highly reliable for refactoring, static analysis, and code completion in their IDEs.
PHP 8 String Functions
New Design for routes:list
New test ‘—coverage’ options display coverage directly in the terminal
Mailer function moved from SwiftMailer to Symfony Mailer.
Improvised Eloquent Accessors/Mutators
Flysystem 3.x
Implicit Route building with Enums (PHP 8.1)
Controller Route Groups
Enum Eloquent Attribute Casting
Forced Scoped Bindings
Laravel Breeze API & Next.js
Laravel Scout Database Engine
Full-Text Indexes and Where Clauses
Inline Blade Templates rendering
Soketi Echo Server
Optional Bootstrap 5 Pagination View
Improvised Ignition Exception Page
New ‘str()’ and ‘to_route()’ helper functions.
How To Install Laravel 9?
If you want to use the new Laravel 9 for development and testing purposes, then you can easily do it now on your machine.
Laravel 9 also supports PHP version 8, so make sure to check your PHP version or do a fresh installation.
Using composer, you can install Laravel 9. Simply run the following command:
composer create-project –prefer-dist laravel/laravel laravel-9-dev dev-develop
The above command will create a new Laravel project with the name Laravel-9-dev that uses the latest Laravel 9.
How To Upgrade Laravel From 8.x to 9?
The up-gradation process may take nearly around 30 minutes.
To Update Dependencies –
Laravel now needs to have PHP 8.0.2 or greater.
Composer Dependencies
Firstly, you will have to update the following dependencies in your application’s composer.json file:
- laravel/framework to ^9.0
- nunomaduro/collision to ^6.1
Once, it is done. Now, replace facade/ignition with “spatie/laravel-ignition”: “^1.0
In the same composer.json file.
Now, see if you are using any third-party packages and verify from the support that now you have Laravel 9 updated.
#PHP Return Types
Laravel 9 has implemented offsetGet, offsetSet, etc. return types in its codebase. These should actually not affect the user-written code, however in case you are overriding one of these methods by extending Laravel’s core classes, then you will have to add the following return types, to your own application packages or to the package code:
- count(): int
- getIterator(): Traversable
- getSize(): int
- jsonSerialize(): array
- offsetExists($key): bool
- offsetGet($key): mixed
- offsetSet($key, $value): void
- offsetUnset($key): void
Now, check if Laravel 9 has been updated.
If you are a newbie or want to migrate to Laravel to build your applications, a reliable Laravel hosting provider is all you need! Explore & choose from our list of top-rated Laravel hosting companies.
If you enjoyed reading this news, you are surely going to cherish these too –
- Cloud Infrastructure Expanded Its Market by 37%, Grew To £131bn in 2021
- SolarWinds Database Performance Analyzer is now available in Azure Marketplace
- Biggest-Ever DDoS Attack In History Terminated by Microsoft