What Is New In Laravel 9 — Features Of Laravel 9

Websolutionstuff
2 min readApr 4, 2022

--

In this article, we will see what is new in laravel 9 and the features of laravel 9. Laravel 9 is recently released 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.

In laravel 9 bug fixes until February 2024 and security fixes until February 2025.

Let’s see list of new features in laravel 9.

  • PHP 8 is the minimum version in Laravel 9
  • New Design for routes:list
  • New test --coverage option displays coverage directly in the terminal
  • Anonymous Stub Migrations are now the default
  • New Query Builder Interface
  • PHP 8 String Functions
  • Moved mailer functionality from SwiftMailer to Symfony Mailer
  • Flysystem 3.x
  • Improved Eloquent Accessors/Mutators
  • Implicit Route Bindings With Enums (PHP 8.1)
  • Controller Route Groups
  • Enum Eloquent Attribute Casting
  • Forced Scoped Bindings
  • Laravel Breeze API & Next.js
  • Laravel Scout Database Engine
  • Full-Text Indexes / Where Clauses
  • Rendering Inline Blade Templates
  • Soketi Echo Server
  • Optional Bootstrap 5 Pagination Views
  • Improved Ignition Exception Page
  • New str() and to_route() helper functions

PHP 8.0

Laravel 9.x requires a minimum PHP version of 8.0.

Anonymous Stub Migrations

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();
});
}
};

Read More : Laravel 9 CRUD Operation Example

New Helper Functions

Laravel 9 adds two new, convenient helper functions that you may use in your own application.

str :

The str function returns a new Illuminate\Support\Stringable instance for the given string.

$string = str('Websolutionstuff')->append('| Web Developing Website');

// 'Websolutiionstuff | Web Developing Website'

to_route :

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

return to_route('users.show', ['user' => 1]);

New Query Builder Interface

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
});

PHP 8 String Functions

In laravel 9 add PHP 8 string functions. It’s \Illuminate\Support\Str class.

  • str_contains()
  • str_starts_with()
  • str_ends_with()

Controller Route Groups

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');
});

--

--

Websolutionstuff
Websolutionstuff

Written by Websolutionstuff

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API. Visit Website: http://websolutionstuff.com/

No responses yet