Features of Laravel 9 : What is new in Laravel 9

Blogs ❯❯ Laravel

Image could not load

Features of Laravel 9

तो जैसा कि आपको पता है कि Laravel 9 कई सारे नए features और performance optimization के साथ release हो चुका है , इस blog में हम देखेंगे कि , Laravel 9 में क्या कुछ नया आया है।

इसके अलावा अभी Laravel के सभी major updates को हर 6 month के बाद release किया जाता है , लेकिन अभी सभी नए updates 1 साल के बाद ही आएंगे , तो आप ऐसा कह सकते हैं कि अगले major updates January 2023 में ही दिखेंगे।

What is Laravel ?

Laravel एक open-source PHP Framework है । Laravel के Important Syntaxes का Use करके हम Web Application बनाते है । Laravel को July 2011 में Taylor Otwell द्वारा बनाया गया था । Laravel MVC (Model , View , Controller) Architecture को follow करता है ।

Key Features of Laravel 9

Laravel 9 में उन सभी improvements को continue किया है जिन्हे Laravel 8.x में implement किया गया था। इसके अलावा कुछ नए features भी introduce किये गए , जैसे - introducing support for Symfony 6.0 components, Symfony Mailer, Flysystem 3.0, improved route:list output, a Laravel Scout database driver, new Eloquent accessor / mutator syntax, implicit route bindings via Enums और usability improvements भी किये हैं।

PHP 8.0 Required

Laravel 9 use करने के लिए minimum PHP version 8.0 हों चाहिए।

Symfony Mailer

Previous Laravel versions में email send करने के लिए Swift Mailer library को utilize किया गया था , हालाँकि इस बार Symfony Mailer को use किया गया है।

Flysystem 3.x

Storage facades , द्वारा सभी type के file interaction को upgrade किया गया है।

Improved Eloquent Accessors & Mutators

Laravel 9 ने accessors & mutators को define करने का एक नया method introduce किया है। पिछले release में accessors & mutators को सिर्फ method द्वारा ही define करते थे। लेकिन अब हम इन्हे single, non-prefixed method का use करके भी define कर सकते हैं।

Example :

/*Laravel version : 9*/ use Illuminate\Database\Eloquent\Casts\Attribute; public function name(): Attribute { return new Attribute( get: fn ($value) => strtoupper($value), set: fn ($value) => $value, ); }

/*Laravel version : 8*/ public function getNameAttribute($value) { return strtoupper($value); } public function setNameAttribute($value) { $this->attributes['name'] = $value; }
Controller Route Groups

अगर आपको याद हो तो , जब कई सारे URL में same prefix अता था तो हम route prefix कर देते थे , जैसे -

Route::group(['prefix' => 'user'], function () 
{
  // now define other routes
});

ठीक इसी तरह अगर कई routes के लिए same Controller use हो रहा है तो वहां पर हम सभी routes के लिए Controller define कर सकते हैं , फिर हमें सिर्फ method define करना है जिस method पर वो request handle करना चाहते हैं।

use App\Http\Controllers\OrderController;
 
Route::controller(OrderController::class)->group(function () {
    Route::get('/orders/{id}', 'show');
    Route::post('/orders', 'store');
});

Rendering Inline Blade Templates

कभी - कभी , हमें raw blade template string को HTML में convert करने की जरूरत पड़ती है तो आप Blade facade के render() method का use करके blade template को render कर सकते हो।

use Illuminate\Support\Facades\Blade;
 
return Blade::render('Hello, {{ $name }}', ['name' => 'Rahul Kumar']);
Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook