What’s New in Laravel 9: An Extensive Look at the New Features

OnGraph Technologies
4 min readMay 25, 2022

--

Laravel 9

Laravel has been one of the most popular PHP frameworks since its launch. It’s simple, easy, scalable, and has become the de facto framework for PHP developers and businesses. Laravel 9 is the most recent version, and it includes numerous new features.

New Laravel releases used to happen every six months, resulting in many queries, criticism, and uncertainty regarding Laravel’s new release strategy. Laravel 9 was released in February 2022 and was the first framework that was released after a 12 months cycle.

Let’s discuss all the new Laravel 9 features and updates announced so far.

Laravel 9 & What To Expect

Laravel 9 is reported to be the first Long Term Support release in a 12-month cycle, with a September 2021 release date first announced. It was later agreed to postpone it until January 2022. Laravel has system dependencies in a variety of community-driven and Symfony 9 modules, and Symfony had intended to deliver Symfony v6.0 by November 2021, causing the Laravel team to postpone the release of Laravel v9. It took some time and a lot of testing and monitoring to upgrade or update the entire Laravel development framework to the most recent version of Symfony before it is released to the market.

On February 8, 2022, Laravel 9 was released as an LTS version. Laravel 9 is compatible with PHP versions 8.0 and 8.1 and includes two years of bug fixes (through February 2024) and three years of security (will receive security fixes until February 2025).

New features in Laravel 9

Let’s look at the list of changes and improvements that are there in the new version of Laravel.

New features in Laravel 9

1. Eloquent accessors/mutators improvement

Taylor Otwell’s Eloquent accessors/mutators feature allows developers to handle database queries using PHP syntax rather than writing SQL code, which can be time-consuming.

To define accessors and mutators in Laravel 8, you must use the get and set prefixes in the model. Using the IlluminateDatabaseEloquentCastsAttribute in Laravel V9, you can declare the prefix with a single non-prefixed phrase. With just one method call, you can now acquire and set characteristics.

2. Minimum PHP requirement

Laravel 9 requires the most recent version of PHP 8, PHPUnit 9, and a few extra requirements that will be provided in the future. Laravel relies on various community-driven and Symfony 9 libraries as a framework. Because Symfony planned to deliver v6.0 in November 2021, the Laravel team had no choice but to postpone the release of Laravel v9. Because Laravel 9 is fully dependent on Symfony’s newest v6.0 release, which requires PHP 8, PHP 8 is required. From the Just-In-Time compiler (JIT) to constructor property promotion, you may learn about what’s new in PHP 8 by looking at the benchmarks for different PHP versions.

3. Anonymous Stub Migration

Anonymous stub migration is the default action when using Laravel’s popular migration command.

php artisan make:migration

Laravel 8.37 added the anonymous stub migration feature to address the Github issue. Several migrations with the same class name can cause complications when attempting to recreate the complete database. The stub migration feature prevents name clashes between migration classes.

4. The new Scout database engine

Laravel v9 comes with the new Laravel Scout database engine. It allows Eloquent models to perform full-text searches. It is a suitable solution for applications that use a small or medium-sized database or have a light workload since it uses model observers to keep search indexes in sync with Eloquent entries. When filtering results from your database, this engine will use “where-like” clauses.

To use it, simply add the Laravel\Scout\Searchable trait to a model.

5. Bootstrap 5 Pagination Views

If you’ve ever had to deal with pagination in your projects, you’ll understand how beneficial having a built-in framework is. Laravel provides automatic pagination, which eliminates the need for manual pagination.

Laravel 9.0, on the other hand, makes this work even easier. Pagination views in Laravel 9 are designed with Bootstrap 5. In the boot method of your AppProvidersAppServiceProvider class, call the useBootstrapFive method.

6. Rendering Inline Blade Templates

Blade templates are used to turn a string into valid HTML when you need to transfer data to HTML.

Blade facades provide a render technique that you may use. The render method takes two arguments: one is a blade string, and the other is an array of data, though the latter is optional.

use Illuminate\Support\Facades\Blade;

return Blade::render(‘Hello, {{ $name }}’, [‘name’ => ‘Julian Bashir’]);

7. Controller Route Groups

The most powerful feature of Laravel 9 is controller route groups. For controller routes, you must use the controller function, then define the routes and their functions for that controller.

That controller will call that method automatically. By combining controller routes, we may avoid duplication of controller usage.

Final Thoughts!

So, here is the complete overview of Laravel version 9 and its updated features. Developers and organizations will benefit from these enhanced versions because they will make their jobs easier and faster.

If you have any additional questions, please contact us and we will gladly assist you. Hope you find this blog informative!

Visit OnGraph Technologies for the latest Tech news and blogs.

--

--

OnGraph Technologies

OnGraph Technologies is an early adopter of innovative technologies of web/mobile app, blockchain, Chatbot, Voicebot, RPA, DevOps https://www.ongraph.com