In this article, we will see what's new in laravel 9 and its features of laravel 9. Laravel 9 is recently released and includes many new features, including a minimum PHP v8.0 version, controller route groups, a refreshed default Ignition error page, Laravel Scout database engine, Symfony mailer integration, Flysystem 3.x, Improved Eloquent accessors/mutators, and many more new features in laravel 9.
Version | PHP (*) | Release | Bug Fixes Until | Security Fixes Until |
---|---|---|---|---|
6 (LTS) | 7.2 - 8.0 | September 3rd, 2019 | January 25th, 2022 | September 6th, 2022 |
7 | 7.2 - 8.0 | March 3rd, 2020 | October 6th, 2020 | March 3rd, 2021 |
8 | 7.3 - 8.1 | September 8th, 2020 | July 26th, 2022 | January 24th, 2023 |
9 (LTS) | 8.0 - 8.1 | February 8th, 2022 | February 8th, 2024 | February 8th, 2025 |
10 | 8.0 - 8.1 | February 7th, 2023 | August 7th, 2024 | February 7th, 2025 |
In laravel 9 bug fixes until February 2024 and security fixes until February 2025.
Let's see the list of new features in laravel 9.
--coverage
option displays coverage directly in the terminalstr()
and to_route()
helper functionsLaravel 9.x requires a minimum PHP version of 8.0.
In laravel 9 restricts migration class name collisions like the below code example.
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('name')->nullable();
});
}
};
Laravel 9 adds two new, convenient helper functions that you may use in your own application.
The str function returns a new Illuminate\Support\Stringable
instance for the given string.
$string = str('Techsolutionstuff')->append('| The Complete Guide');
// 'Techsolutionstuff | The Complete Guide'
to_route:
The to_route function generates a redirect HTTP response for a given named route.
return to_route('users.show', ['user' => 1]);
In laravel 9 you can write queries like the below code.
return Model::query()
->whereNotExists(function($query) {
// $query is a Query\Builder
})
->whereHas('relation', function($query) {
// $query is an Eloquent\Builder
})
->with('relation', function($query) {
// $query is an Eloquent\Relation
});
In laravel 9 add PHP 8 string functions. It's \Illuminate\Support\Str class.
You may now use the controller method to define the common controller for all of the routes within the group
use App\Http\Controllers\OrderController;
Route::controller(OrderController::class)->group(function () {
Route::get('/orders/{id}', 'show');
Route::post('/orders', 'store');
});
You might also like: