Laravel 12: What’s New From 12.0 to 12.19 – A Complete Guide
July 20, 2025🔧 1. Laravel 12.0 – Starter Kits & Core Changes
Version 12.0 introduced modern starter kits for React, Vue, Livewire, plus integration with WorkOS AuthKit, type-safe code, and PHPUnit 12 support.
React/Vue Starter Kit
Scaffold new apps with Inertia 2, TypeScript, shadcn/ui, and Tailwind:
composer create-project laravel/laravel my-app --prefer-dist
cd my-app
php artisan breeze:install react --typescript
# or
php artisan breeze:install vue --typescript
WorkOS AuthKit (Social Login, SSO, Passkeys)
Easily integrate social logins:
// config/workos.php
return [
'client_id' => env('WORKOS_CLIENT_ID'),
'api_key' => env('WORKOS_API_KEY'),
'redirect_uri' => env('WORKOS_REDIRECT_URI'),
'providers' => ['google'=>true,'github'=>true,'microsoft'=>true],
'passkeys' => ['enabled'=>true,'rp_name'=>env('APP_NAME'),'rp_id'=>env('APP_DOMAIN')],
];
Use this controller snippet:
public function callback() {
$workos = new WorkOS(config('workos.api_key'));
$profile = $workos->sso->getProfile(request('code'));
$user = User::firstOrCreate(['email'=>$profile->email], [
'name'=>$profile->firstName.' '.$profile->lastName,
'workos_id'=>$profile->id,
]);
auth()->login($user);
return redirect()->intended('/dashboard');
}
PHPUnit 12 Support & Type-Safe Requests
Laravel now supports PHPUnit 12 and encourages typed request helpers:
public function store(Request $req): JsonResponse {
$user = User::create([
'name' => $req->string('name')->value(),
'email' => $req->string('email')->value(),
'prefs' => $req->collect('preferences')->toArray(),
]);
return response()->json($user, 201);
}
🧩 2. Laravel 12.1 – Arr::partition()
& HTTP enhancements
The new Arr::partition()
splits arrays by condition:
$numbers = [0,1,2,3,4,5];
[$evens, $odds] = Arr::partition($numbers, fn($n)=>$n%2===0);
// $evens = [0,2,4], $odds = [1,3,5]
You can also now truncate Http exceptions per request:
Http::truncateExceptionsAt(240)
->post('https://example.com/api', [...]);
⚙️ 3. Laravel 12.19 – Custom Builders, Fluent Casts, Fail-on-Exception Middleware
@useEloquentBuilder
: attach custom Eloquent builders to models.Fluent Casts
: cast attributes to objects, e.g. URI.- Fail-On-Exception Middleware: auto-fail jobs on throttle exceptions.
Example model-level custom builder:
#[useEloquentBuilder(MyBuilder::class)]
class Post extends Model {
// now queries use MyBuilder
}
📋 4. Minor Changes & Quality-of-Life Updates
String::doesntStartWith()
&doesntEndWith()
.- Better JSON Serializable support in URIs.
- Queue/ Pagination enhancements, logs improvements.
- SVGs now excluded from default
image
validation unless allowed.
💡 Practical Tips for Projects
- ✅ Use starter kits for fast bootstrapping.
- 🔍 Use
Arr::partition()
instead of manual collection partition. - 🛡️ Truncate HTTP exceptions to control log sizes.
- 🧰 Use custom builder & fluent casts for cleaner models.
- 🧪 Update PHPUnit and Carbon 3 for tests.
- ⚠️ Allow SVG explicitly if needed:
'photo' => 'image:allow_svg'
.
Blog
Comparison between Scopes + Traits × UseEloquentBuilder in Laravel
Jul 13, 2025
Laravel provides multiple ways to write reusable query logic. The two most common approaches are using Scopes with Traits or the newer #[UseEloquentBu...
React Native 0.80 & ExecuTorch: A Powerful Leap into Offline AI for Mobile Apps
Jul 28, 2025
🚀 What’s New in React Native 0.80? The React Native 0.80 release marks a pivotal moment in mobile development. This update not only enhances...
Mastering Laravel Context: Advanced Logging and Contextual Job Tracing
Jul 20, 2025
Laravel Context is one of the most powerful new features in Laravel 12. It allows you to attach contextual data (like user ID, IP address, request pat...
Color Everything in CSS – Simple Guide
Jun 26, 2025
Color Everything in CSS – Simple Guide Today we’re diving into CSS colors: how to define them, especially with modern methods like lab(...
Laravel 12.19: Elegant Query Builders with PHP Attributes
Jul 07, 2025
Laravel 12.19: Elegant Query Builders with PHP Attributes In Laravel 12.19, you can now use the #[UseEloquentBuilder] PHP attribute to assign a cus...
React Labs: View Transitions & Activity
Jun 17, 2025
React Labs: View Transitions & Activity Published April 23, 2025 by Ricky Hanlon. React Labs is sharing two new experimental featu...
