This week, a free, open-source PHP web framework, Laravel, created by Taylor Otwell, was updated to version 9.0. Initially, the release was planned for 2021, but as we wrote in July last year, the date was moved to January 2022. And then moved once again - to February. Now the version has become available. It will receive long-term support. It means that bug fixes will be available until the 8th of February 2024 and security fixes - until the 8th of February 2025.
The new version contains numerous changes that may cause incompatibility in the apps developed for the previous versions. The detailed list is posted here. However, we also will share some of them below:
- The new version of Laravel now can’t be used with PHP less than 8.0;
- Swift Mailer library, which was used to send emails and is no longer maintained, was replaced with Symfony Mailer;
- Flysystem, the component responsible for interactions with the files, was updated to 3.x;
- Implemented ability to define an accessor and mutator with a single non-prefixed method;
- Eloquent allows to cast attribute values to PHP enums (please note that they are available in PHP 8.1 and higher only);
- Forced scopes in route bindings. Laravel can be instructed to scope “child” bindings even if a custom key is absent;
-
controller
method can be used to set a common controller for all the routes in the group; - Full-text indexes can be generated when using PostgreSQL or MySQL by adding the
fulltext
method to the column definitions; - Scout Database Engine can be used with small databases without a heavy load. It uses “where like” clauses and full-text indexes to find the needed results;
- Inline Blade templates can be converted into valid HTML;
- New Blade directives -
checked
andselected
to verify the conditions of the options on the page; - Slot naming simplified;
- Pagination views using Bootstrap 5 can be used now instead of the Tailwind views;
- Validation for the nested array elements was improved;
- Ignition debug page was redesigned;
- Improvements to the
route:list
command line output; - New
coverage
option added to theartisan test
command; - Laravel Echo now can use Web Socket server Soketi;
- New helper functions -
str
(equivalent toStr::of
method) andto_route
, which generates a redirect HTTP response.