Skip to content

What’s new in Laravel 9

What is Laravel?

Laravel is an open-source PHP framework for building full-stack web applications. Laravel is a framework not a CMS and it gives you full control over the application. Laravel takes care of a lot of the things that are hard to develop yourself such as routing, HTML templating, and authentication.


Why use Laravel and what are its features?

1. Support and community
2. Security
3. Exceptional Support & Performance Using MVC Architecture
4. Database Interaction Made Simple with Eloquent ORM
5. Artisan CLI For Extremely Easy & Quick Commands
6. A Template Engine for Exceptional Layouts
7. Testing
8. Automatic Pagination


Laravel 9

It was initially scheduled to be released by September 2021, Laravel 9’s release was pushed to January 2022 and was finally released on February 8th, 2022. Laravel 9 includes a minimum PHP 8.0 version, controller route groups, an updated default Ignition error page, Laravel Scout database engine, Symfony mailer integration, Flysystem 3.x, improved Eloquent accessors/mutators, and many more features.


What’s new in Laravel 9?

1. Anonymous Stub Migrations

The main issue is that if many migrations have the same class name, it may cause problems when attempting to rebuild the database from scratch.

Laravel 9 Setup Screen

2. New Query Builder Interface

Laravel 9 has a new Query Builder Interface, which you can learn more about in this merged PR.

New Query Builder Interface - Laravel 9

3. Laravel 9 requires PHP 8 as a minimum version.

Laravel 9 will need Symfony 6.0, which has a minimum requirement of PHP 8, implying that Laravel 9 would be restricted in the same way. Since Laravel 9 depends on PHP 8 Tom Schlick submitted a PR to move to using str_contains(), str_starts_with() and str_ends_with() functions internally in the \Illuminate\Support\Str class.

4. New Design for (routes:list)

When using the (php artisan routes:list) command, if you have a large number of complicated routes specified, it might be difficult to examine them in the Laravel 9 this command was changed for much more pretty.

New Design for (route:list) - Laravel 9

5. New Test Coverage Option
A new (php artisan test –coverage) command option will display the test coverage directly on the terminal.

New Test Coverage Option - Laravel 9

6. From SwiftMailer to Symfony Mailer
To send outgoing emails, previous versions of Laravel used the Swift Mailer package. However, that library is no longer available and Symfony Mailer has taken its place. To discover more about Symfony Mailer check out this upgrade guide.

7. Laravel Scout Database Engine
Laravel Scout originally launched with a focus on Algolia. However, since then several alternative “engines” have been introduced. As part of Laravel 9, for small to medium-sized applications, you may decide to leverage the new database engine.

8. Laravel Breeze API & Next.js
An “API” scaffolding mode has been added to the Laravel Breeze starting kit as well as a companion Next.js frontend implementation. This starting kit scaffolding can be used to get your Laravel backend, Laravel Sanctum authenticated API, and JavaScript frontend up and running quickly.

9. Controller Route Groups

The controller method may now be used to establish a common controller for all the routes in the group. You simply need to supply the controller method that they invoke when establishing the routes:

Controller Route Groups - Laravel 9

10. Bootstrap 5 Pagination Views

Pagination views developed with Bootstrap 5 are now included in Laravel. You may call the paginator’s useBootstrapFive function within the boot method of your App\Providers\AppServiceProvider: class to utilize these views instead of the default Tailwind views.

Bootstrap 5 Pagination Views - Laravel 9

11. Enum Eloquent Attribute Casting

You may now cast your attribute values to PHP Enums in Eloquent. To do so, put the attribute and Enum you want to cast in the $casts property array of your model:

Enum Eloquent Attribute Casting - Laravel 9

When you interact with an attribute after you’ve declared the cast on your model, the provided attribute will be automatically cast to and from an Enum:

Enum Eloquent Attribute Casting

12. Improved Ignition Exception Page

Spatie’s open-source exception debug page Ignition, has been completely redone from the bottom up. Light / dark themes, adjustable “open in editor” features, and more are included in the new, better Ignition that ships with Laravel 9.x .

Improved Ignition Exception Page - Laravel 9

13. New Helpers
Laravel 9.x includes two new, useful auxiliary methods that you may utilize in your own code.
The str function returns a new Illuminate\Support\Stringable instance for the given string. This function is equivalent to the Str::of method:

New Helpers - Laravel 9

If the str function is used without an argument, it returns an instance of Illuminate\Support\Str:


New Helpers (to_route) - Laravel 9

If necessary, you need to pass to HTTP status code that should be assigned to the redirect and any additional response headers as the third and fourth arguments to the to_route method:

14. The server.php file can be removed

It’s a little change, but you can now delete the server.php file from your project and the framework will still include it. Only php artisan serve makes use of this file.


Laravel 9 is now released, major updated versions will be released every 12 months and there will be more new features and announcements. We’ll keep this site updated when more details become available. You may also go to the official release website to learn more.