What Is New In Laravel 9 - Features Of Laravel 9

Websolutionstuff | Feb-13-2022 | Categories : Laravel

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.

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

 

 

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

 


You might also like :

Recommended Post
Featured Post
Laravel 9 Insert Multiple Records In Database
Laravel 9 Insert Multiple Reco...

In this article, we will see laravel 9 insert multiple records in the database. Here, we will learn how to ins...

Read More

Dec-16-2022

Node.js Express CRUD Example with MySQL
Node.js Express CRUD Example w...

Hello Guys, In this tutorial we will see how to perform Node js Express CRUD example with mysql. Node js Express ...

Read More

Aug-02-2021

How To Create Web Notifications In Laravel 9 Using Pusher
How To Create Web Notification...

In this article, we will see how to create web notifications in laravel 9 using pusher. Here, we will learn how to...

Read More

Feb-03-2023

How To Copy Text To Clipboard In React JS
How To Copy Text To Clipboard...

In this article, we will see how to copy text to the clipboard in react js. you will learn how to copy text to...

Read More

Aug-31-2022