If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.

Laravel 12
अगर आप एक PHP developer है, तो Laravel 12 का wait करना natural है ! Laravel 11 ने जो foundation दिया, उस पर Laravel 12 और भी speed, simplicity, और power लेकर आया है।
चलो देखते हैं, इस बार क्या नया है।
●●●
पहले $casts array use करते थे model में -
protected $casts = [
'birthday' => 'date',
'metadata' => 'array',
];अब आप casts() method use कर सकते हो, जो ज़्यादा readable है -
public function casts(): array
{
return [
'birthday' => 'date',
'metadata' => 'array',
];
}Laravel 12 ने Pest को default testing framework बना दिया है। PHPUnit कि जगह, Pest से आप tests लिखने में 50% कम time लगा सकते हो।
test('user can login', function () {
$user = User::factory()->create();
$this->post('/login', [
'email' => $user->email,
'password' => 'password',
])->assertRedirect('/dashboard');
});Note* Syntax PHPUnit से ज़्यादा simple है, और syntax errors कम होते हैं।
अब आप अपनी Laravel app का health check एक route से कर सकते हो ! Laravel 12 new php artisan make:health command के साथ आता है, जो एक /health route बनाता है।
जो कुछ important चीज़ें Check करता है -
Database connection
Redis status
Cache driver
Disk space
Usage
php artisan make:health
Browser में जाओ https://yourapp.com/health – सब कुछ green दिखेगा तो app fit है :)
पहले अगर आप with() और load() use करते थे, वो same नहीं थे, Laravel 12 ने with() और load() को sync कर दिया है।
$users = User::with('posts')->get();
$users->load('comments'); // Ab yeh bhi same $users instance par apply hoga! Advantange : Code confusion कम, और performance better!
php artisan make:enum → Enum class बनाये php artisan make:interface → Interface generate करे php artisan make:trait → Trait बनाये
Bonus : अब आप custom stubs बना सकते हो हर command के लिए।
Example -
php artisan stub:publish
Laravel 12 के लिए अब PHP 8.2 चाहिए , इसका मतलब आपको PHP 8.2 के सारे features मिलेंगे जैसे -
readonly classes
array_is_list() function
Randomizer class
Routes cache (php artisan route:cache) अब 2x faster है, especially large projects में।
●●●
Comment करके बताएं : "Laravel 12 का कौन सा feature आपको सबसे पसंद आया ?"
Loading ...