What Is New In Laravel 9 - Features Of Laravel 9

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

    You might also like :

Bình luận
Vui lòng đăng nhập để bình luận
Một số bài viết liên quan