What’s New In Laravel 9

Laravel 9
Image by petim from Pixabay

Laravel is an Open Source MVC framework that is used to build simple to complex PHP web applications. In this post, we will see different features added in laravel 9.

Laravel 9 is now released with new features like Anonymous Stub Migrations, PHP 8 String Functions, Controller Route Groups and many more! PHP 8 is the minimum version in Laravel 9. Let’s unpack it one by one.

routes:list output formatting

You will see Console output of the PHP artisan command route:list properly formatted to view bulk routes. It makes console output more readable now.

Anonymous Stub Migrations

This feature, which was included in laravel 8.37 to prevent migration class name collision is now default when we run php artisan make:migration

PHP 8 String Functions

As laravel 9 supports PHP 8, it uses latest PHP 8 string functions like str_contains(), str_starts_with(), and str_ends_with() internally in the \Illuminate\Support\Str class.

Flysystem 3.x

Laravel 9.x upgrades upstream Flysystem dependency to Flysystem 3.x. Flysystem supports all of filesystem interactions offered by the Storage facade.

Controller Route Groups

You may now use the controller method to define the common controller for all of the routes within the group. Then, when defining the routes, you only need to provide the controller method that they invoke.

Laravel Scout Database Engine

Laravel 9 Scout Database Engine will use “where like” clauses and full text indexes when filtering results from your existing database to determine the applicable search results for your query.

Rendering Inline Blade Templates

Now you can transform a raw Blade template string into valid HTML using render method. The render method accepts the Blade template string and an optional array of data to provide to the template:

use Illuminate\Support\Facades\Blade;
return Blade::render('Hey, {{ $data }}', ['data' => 'Code Topology']);

Bootstrap 5 Pagination Views

Now you can change default Tailwind view and use latest bootstrap 5 pagination view. You may call the paginator’s useBootstrapFive method within the boot method of your App\Providers\AppServiceProvider class.

Improved Exception Page

The new, improved Ignition ships with Laravel 9.x and includes light / dark themes, customizable “open in editor” functionality.

str and to_route helpers

You can use 2 New helpers in laravel 9: str and to_route

str function will return Illuminate\Support\Stringable instance for the given string.

to_route function generates a redirect HTTP response for a given named route.

There are many other features are added that are not covered in this post like Echo Server, Full Text Indexes, Laravel Breeze API, Scoped Bindings etc. You can read complete details on official release page.

Leave a Reply

Your email address will not be published. Required fields are marked *