Developers can rejoice – Laravel 9 has been released and contains several new features. Laravel 9 also marks the start of their 12-month release cycle. Prior to this release, Laravel announced their major updates every six month but that has increased now to 12-month intervals.
As one of the most prevalent PHP frameworks out there, it performs with elegance and scalability and has become the go-to framework for those working with PHP. Created in 2011 by Taylor Otwell, Laravel was intended to replace the PHP framework CodeIgniter since the latter did not offer some features that many considered important. It started out in beta but quickly released Laravel 1 soon after with a subsequent version being released every six months since.
This framework has already had some essential features introduced: the ORM Eloquent, which permits an all-in-one interaction between the user and the data model and database of their choosing, an Artisan CLI, which is a command line that users can utilize to create Laravel without the need to access folders and files, outstanding security features, and more.
With the release of Laravel 9, we can expect to see many new and impressive features as well as some improvements to features that have been around for quite some time.
Improvement to Eloquent Accessors and Mutators
Prior to Laravel 9, in order to use eloquent accessors and mutators, the user would have to obtain and set prefixes. This changes in the update and now users will only need to declare the prefix using a non-prefixed term which means that attributes can now be established with just one method call.
This is especially important as eloquent accessors and mutators help developers in saving time by allowing them to handle database queries with PHP syntax as opposed to having to write SQL code. With these improvements, laravel web developers can expect to save even more time now.
Controller Route Groups
One of the most important features of Laravel 9 is the controller route groups. In order to use this feature, you will need to utilize the controller function and define the routes and their subsequent functions for that controller. Once this is done, a method will automatically be used. This will assist in the avoidance of repeating the use of the controller.
Forced Scoping of Route Bindings
In earlier versions of Laravel, scoping was done by using the parent eloquent model. In Laravel 9, however, a function called Scope Bindings Method has been created to define your route. This means that the child model will receive instructions from the parent even with no key given.
In addition to this, binding a scope for an entire group of routes is now possible with use of the group function.
In earlier versions, developers needed to create specific conditions in order to select the checkbox and dropdown. Laravel 9 intends on resolving this issue with the use of @checked and @selected blade components. The data will be selected once a specific condition is true which developers will write in the checked and selected components.
Improved Page for Ignition Exception
The open-source exceptions debugging page, brought to us by Spatie, has received some prominent updates as well. Two of the most popular additions to this Laravel open-source debugging page are the choice between a light and dark theme and the ability to customize “open in editor.” In addition to these new updates, the default error page for Laravel 9 will now be the Ignition page.
Some other important additions to Laravel 9 are:
- New design implemented for routes:list
- Introduction of a new interface for the query builder
- Bootstrap 5 Pagination Views (optional)
- New helper functions: str() and to_route()
- Option to directly display coverage in the terminal by using –coverage
- Replacing SwiftMailer with SymfonyMailer
- And much more
Installing Laravel 9
Keep in mind, developers: only PHP version 8 can be used by Laravel so be sure that you check that your version is up-to-date before installing Laravel 9. Should you have an older version, make sure to remove it and begin a new installation. This will make the process easier.
Once you ensure that your PHP version is current, you can proceed to installing and operating Laravel 9 on your device. To do this, we recommend using the following commands in order to employ the Laravel 9 update:
composer create-project –prefer-dist laravel/laravel laravel-9-dev dev-develop
This will ensure that you are developing a new Laravel project with the latest Laravel version. In this case, Laravel 9.
Alternatively, you could also use the Laravel Global CLI to update your Laravel. Once you have done this, you can proceed to build a new project by first using the developer branch.
After you have Laravel 9 installed on your device, you should head on over to the new directory and evaluate the current version by using the artisan command. Note that the new directory should be called laravel-dev.
The artisan command that you need to use to make your evaluation is:
php artisan –version
This will ensure that your version is updated and ready to run.
The above-mentioned features are just a few that have been introduced in Laravel 9 but these updates are sure to make it easier for developers in the long-run. Now that they have changed to a 12-month cycle for their major releases, you can expect to see Laravel 9 be prevalent for a long time. They even guarantee that bug fixes will be issued for 18 months while security updates will happen for the next two years.
In addition to all of these nifty features introduced in the Laravel 9 framework, their website has also been improved. They have updated their design for their home page with a design by Martin Rariga to celebrate the release of Laravel 9.
If you want to read more about the new features and functions that come with Laravel 9, be sure to check out the official Laravel 9 release notes.