×

What’s New in Laravel 9 from ByteFum
New Features in Laravel
Feb 14, 2022
Auther Avatar Laravel
Description

Key Features of Laravel 8/9 yes

If you’re new to this framework, we’ve curated some of the best Laravel features to give you a better understanding.

Key Features of Laravel 8 yes

1. Eloquent ORM

The object-relational mapper (ORM) for Laravel is called Eloquent, and it’s one of the best features of Laravel as it allows for seamless interaction with the data model and database of choice.

With Eloquent, Laravel abstracts every hurdle involving interacting with and writing complex SQL queries to access data from your database.

2. Artisan CLI

The Artisan CLI, or command line, is another vital aspect of Laravel. With it, you can create or modify any part of Laravel from the command line without having to navigate through folders and files.

With Artisan, you can even interact with your database directly from your command line using Laravel Tinker — all without installing a database client.

3. MVC Architecture

The MVC architectural nature of Laravel makes the language relatable and adaptable because it follows a prevalent web development pattern with ongoing, significant improvements.

Laravel will force you to learn and understand the MVC architectural pattern, popular and used in almost all frameworks, such as AdonisJS from JavaScript and ASP.NET MVC from C#.

4. Automatic Pagination

If you’ve ever struggled with pagination in your applications, you’ll understand the value of having your pagination sorted out by a built-in framework.

Laravel solves the pagination hassle by building automatic pagination that comes right out of the box. This feature is one of its most recognized ones, and it eliminates the work involved in solving the pagination mystery yourself.

5. Security

Laravel comes with many security measures due to its adherence to the OWASP security principles. From cross-site request forgery (CSRF) to SQL injection, Laravel has a built-in solution for it all.

 

What’s New in Laravel 9 yessmiley

 The latest Laravel version is version 9, which was released on February 8, 2022.

1. Minimum PHP Requirement

First and most importantly, Laravel 9 requires the latest PHP 8 and PHPUnit 8 for testing. That’s because Laravel 9 will be using the newest Symfony v6.0, which also requires PHP 8.PHP 8 has significant improvements, and features, from the JIT compile to constructor property promotion.

2. Anonymous Stub Migration

Earlier this year, Laravel 8.37 came out with a new feature called Anonymous Migrations that prevents migration class name collisions.


 

1use Illuminate\Database\Migrations\Migration;

2use Illuminate\Database\Schema\Blueprint;

3use Illuminate\Support\Facades\Schema;

5return new class extends Migration {

7 /**

8 * Run the migrations.

9 *

10 * @return void

11 */

12 public function up()

13 {

14 Schema::table('people', function (Blueprint $table) {

15 $table->string('first_name')->nullable();

16 });

17 }

18};

When Laravel 9 launches, this will be the default when you run php artisan make:migration

3. New Query Builder Interface

With the new Laravel 9, type hinting is highly reliable for refactoring, static analysis, and code completion in their IDEs. Due to the lack of shared interface or inheritance between Query\Builder, Eloquent\Builder, and Eloquent\Relation. Still, with Laravel 9, developers can now enjoy the new query builder interface for type hinting, refactoring, and static analysis.

<?php

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

This version added the new Illuminate\Contracts\Database\QueryBuilder interface, as well as the Illuminate\Database\Eloquent\Concerns\DecoratesQueryBuilder a trait that will implement the interface in place of the __call magic method.

4. PHP 8 String Functions

Since Laravel 9 targets PHP 8, Laravel merged this previous request, suggesting using the newest PHP 8 string functions.

These functions include the use of str_contains()str_starts_with(), and str_ends_with() internally in the \Illuminate\Support\Str class.

Recommended Blog
×
Nishan Avatar
Quick Enquire