Is Laravel 9 Really A Beast? šŸ˜¼

UI-Lib
5 min readMar 29, 2022

Laravel the open-sourced PHP web framework has undoubtedly become one of the go-to web development frameworks amongst web artisans who prefer working with PHP. The robust amount of features that it offers us makes it adaptable, scalable, and elegant. The most interesting thing about Laravel is that it takes care of much of the code for us.

It is based on PHP and strictly follows the MVC architecture. It always focuses on making the web development process faster and smoother which is why it continuously gets updated. Though the continuous update may seem unpleasant to some developers, Laravel is doing it for adding more functionalities and features for our ease.

Laravel's recent version Laravel 9 includes the first LTS or Long-Term Support which introduced 12-month release support. It was initially scheduled to release in September 2021 but for some reason was released in February 2022. One of the reasons that it was pushed to be released later was getting perfectly adjusted with Symfonyā€™s new release Symfony v6.0.

Note: The blog contains affiliate links.

New Features in Laravel 9

Minimum PHP Requirement

Laravel 9 requires the newest PHP version 8.0. As Laravel 9 uses Symfony v6.0 and Symfony v6.0 also requires PHP 8.0 it is necessary to keep the PHP version up to date to start working with Laravel 9. Also, this enables us to enjoy the newest features of PHP version 8.0 some of which are JIT or Just In Time compiler, named arguments, the OPcache extension, and many more.

Symfony Mailer

The most considerable change in Laravel 9 is transferring from Swift Mailer to Symfony Mailer. The earlier versions of Laravel used Swift Mailer but it is extinct from the recent release and will no longer be added to the newer releases of Laravel.

Anonymous Stub Migration

Previously it was seen that Laravel had a Github issue that was getting an error when running the well-known migration command and performing multiple migrations with the same class name. The recent Laravel 9 introduced Anonymous Stub Migration for that reason which eliminates the collision between the same class name during migration.

New Query Builder Interface

Laravel 9 made type hinting more reliable with its new Query Builder Interface. Earlier as it was quite difficult to understand whether one was working with Query\Builder, Eloquent\Builder, or Eloquent\Relation as they didnā€™t share any interface or inheritance among them. But Laravel 9 fixed this issue by coming up with a new interface of query building for type hinting, refactoring, and static analysis.

Filesystem 3.x

Laravel 9 updated its filesystem to the latest 3.x version. All the record manipulation strategies and interactions with our filesystem offered by the Storage facade is powered by Filesystem.

Controller Route Groups

Now we can route groups in a specific controller method with Laravel 9.

use App\Http\Controllers\BlogController;

Route::controller(BlogController::class)->group(function () {
Route::get('/blog/{id}', 'show');
Route::post('/blog', 'store');
})

Breeze API with Next.js

Laravel 9 added Next.js frontend implementation on its Breeze starter kit. By scaffolding the Breeze starter kit, Laravel can now be used as both backend and JavaScript frontend using Laravel Sanctum Authentication.

PHP 8 String Functions

As Laravel 9 uses PHP 8, it incorporated the use of the newest addition in PHP 8 string functions which arestr_contains() , str_starts_with() , str_ends_with() , etc in the \Illuminate\Support\Str class.

Inline Blade Rendering

Laravel 9 supports inline blade rendering which helps to render raw blade templates into valid HTML.

use Illuminate\Support\Facades\Blade;

return Blade::render('Hello, {{ $text }}', ['text' => 'Welcome to UI-Lib!']);

Improved Accessor and Mutators in Eloquent

Previously in Laravel accessors and mutators were defined by prefixed methods. But in Laravel 9 single, non-prefixed methods can be used to define accessors and mutators. Now with one method call, we can both get and set attributes.

use Illuminate\Database\Eloquent\Casts\Attribute;public function name(): Attribute{return new Attribute(get: fn ($value) => strtoupper($value),set: fn ($value) => $value,);}

Scout Database Engine

Laravel 9 comes with the Scout Database Engine. It is preferred when handling a small or medium database or one which has a light workload. It offers full-text search capabilities and uses model observers to keep search indexes in sync with Eloquent records. This database engine uses ā€œwhere likeā€ clauses for filtering data from records.

The features described above are not the only features added to Laravel 9. To get a good glance at what other properties Laravel added to its newest release please visit Laravel 9 Release Notes.

Install and Start Working With Laravel 9

To start a project with laravel 9 two approaches can be taken but first one must ensure that he/she has PHP 8.0 installed,

For installing and starting a project with Laravel 9 using Composer, run the following command,

composer create-project laravel/laravel laravel-9-project 

This will create a folder called ā€œlaravel-9-projectā€ which will have all the files and components necessary for building a project with laravel.

Another way to install and start a project with Laravel 9 is by using Laravel global CLI. For this, run the following command,

laravel new laravel-9-project

This will do the same as mentioned above after starting a Laravel 9 project with Composer.

Conclusion

Laravel is always working for the ease of its developers. It was getting updated quite regularly so that developers can enjoy writing their code and building their projects. But taking care of most of the code for the developers is not an easy task, many issues were faced, which is why Laravel needed to update quite regularly. But Laravel 9 introduced its first LTS release and made sure all issues that were shown previously are no longer available. This surely made Laravel 9 a beast compared with all the previous versions.

Our Products Made With Laravel

Gull ā€” Bootstrap & Laravel Admin Dashboard Template

Aatrox ā€” Laravel & TailwindCss Admin Dashboard Template

WorkTick ā€” Ultimate HRM & Project Management Software With Laravel

Stocky ā€” Ultimate Inventory Management System with Pos Implemented with Laravel

Relevant Articles

If you want to know more about us, please visit UI-Lib.

--

--

UI-Lib

At UI-Lib you can download hand coded free and premium Admin Dashboards, Landing pages, UI Kits & Design Systems built with Angular, React & Bootstrap, etc.