Laravel 11 : What is new | Laravel 11 updates

Other Blogs

Blogs ❯❯ Laravel

Image could not load

Laravel 11 Updates

Agar आप PHP और Laravel का इस्तेमाल करते हैं, तो Laravel 11 का launch आपके लिए एक बड़ा update है! Laravel 10 के बाद, इस नए version में performance improvements, developer-friendly features, और simplified code structure लाया गया है।

चलिए जानते हैं कि Laravel 11 में क्या-क्या नया है, और ये आपके projects के लिए क्यों ज़रूरी है।

1. Minimal Application Skeleton

पहले नया Laravel project बनाते time, बहुत सारी default files (जैसे Kernel.php, Exception Handler) create होती थीं, जिनकी ज़्यादातर developers को ज़रूरत नहीं होती।

Laravel 11 में Solution

अब नया project create करने पर कम files generate होंगी, जिससे Project structure clean और lightweight हो गया है।

Example

  • app/Http/Kernel.php अब automatically framework में include है।

  • bootstrap/app.php को simplify किया गया है।

2. Health Check Route

Laravel 11 में एक नया /up route add किया गया है, जो आपके app की health check करता है। ये route check करता है -

  • Cache driver

  • Database Connection

  • Queue workers

कैसे Use करें?

बस browser में खोलें : https://yourapp.com/up , अगर सब कुछ ठीक है, तो "OK" दिखेगा।

3. Per-Second Rate Limiting

पहले rate limiting केवल per-minute basis पर होती थी। Laravel 11 में अब आप seconds में भी limit set कर सकते हैं।

// API routes पर 10 requests per second RateLimiter::for('api', function (Request $request) { return Limit::perSecond(10); });

इससे APIs को और secure बनाने में मदद मिलती है।

4. New Upgrade In Model Casts

Model में $casts array को अब method के रूप में define किया जा सकता है।

In Laravel 10

protected $casts = [ 'birthday' => 'date', 'metadata' => 'array', ];

In Laravel 11

public function casts(): array { return [ 'birthday' => 'date', 'metadata' => 'array', ]; }

5. "Once" Method For Event Listeners

अब आप event listeners को सिर्फ एक बार execute कर सकते हैं।

Event::once(function (OrderShipped $event) { // ये code सिर्फ एक बार चलेगा });

6. PHP 8.2 Support

Laravel 11 को चलाने के लिए अब PHP 8.2 ज़रूरी है। इसके साथ आप PHP 8.2 के नए features जैसे readonly classes और array_is_list() का भी use कर सकते हैं।

7. New Artisan Commands

  • php artisan make:class → नई class create करें।

  • php artisan schema:dump → Database schema को dump करने के लिए।

Hey ! I'm Rahul founder of learnhindituts.com. Working in IT industry more than 5.5 years. I love to talk about programming as well as writing technical tutorials and blogs that can help to others .... keep learning :)

Get connected with me - LinkedIn Twitter Instagram Facebook

Your Thought ?

Please wait . . .

    Recent Blogs

    Loading ...

    0 Comment(s) found !