What’s New in Laravel 9
Laravel 9 is here, and along with it comes a wide array of useful new features and tweaks. This includes an improved accessor/mutator API, better support for Enum casting, forced scope bindings, a new database engine for Laravel Scout, and so much more.
If you have 45 minutes to spare, I’ll show you everything you need to know to get up to speed.
Controller Route Groups
First up on our list is a new Route::controller() method that may help to shorten and simplify routes that share a common controller namespace.
Anonymous Migration Classes
This next one is just a little tweak, but it’s still something to be aware of. When generating migration classes, you’ll notice that Laravel now leverages anonymous classes.
New Helper Functions
Upon installing Laravel 9, you’ll notice two new global helper functions – str() and to_route(). Let’s quickly review both.
Refreshed Ignition Error Page
Next up, you’ll quickly notice that the Ignition team has freshened up Laravel’s error page.
Render a Blade String
You may not reach for this next addition too often, but it’s there when you need it. You can now, through a simple method call, render a Blade-formatted string to HTML.
Forced Scope Bindings
In Laravel 9, you can now “turn on” forced scope bindings in your route declarations through a simple method call. You may find that this adds just a bit more clarity and intent.
Test Coverage with XDebug
Recently, Laravel added a new php artisan test command to trigger suite. This functionality has now been extended to include generating a code coverage report. As long as you have Xdebug installed (which we’ll do in this episode), you’ll find this to be of great convenience.
Laravel Scout Database Engine
Laravel Scout originally launched with a focus on Algolia. However, since then, a number of 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.
Full Text Indexing
Laravel 9 also includes better support for MySQL or PostgreSQL full text indexing. You’ll find a new fulltext() method when preparing new migrations, as well as a whereFulltext() method on your Eloquent builder.
Enum Attribute Casting
Now that PHP 8 offers first-class support for enums, Laravel 9 has been updated to include Eloquent attribute casting to and from an enum object.
Simplified Accessors and Mutators
Laravel’s traditional getXAttribute and setXAttribute API for declaring accessors and mutators is not going away
however, there’s a new, simplified approach that will be recommended going forward. Let’s have a look.
User Reviews
Be the first to review “What’s New in Laravel 9”
You must be logged in to post a review.
There are no reviews yet.