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
imagevalidation 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
Laravel 12.18.0 Update
Jun 17, 2025
Laravel 12.18.0 Update The Laravel team released version 12.18.0 with several cool updates: String encrypt() & decrypt() helpers are...
Analyze Laravel Projects with Introspect
Jul 01, 2025
Analyze Laravel Codebases with Laravel Introspect If you’re doing a complex refactor or building dev tools, Laravel Introspect helps you quer...
What’s New in ECMAScript 2025
Jun 30, 2025
What’s New in ECMAScript 2025 On June 25, 2025, Ecma International officially approved ES2025, adding several useful features: 1. 📦 Import At...
Stop Copy-Pasting Code! Learn How to Use Traits in Laravel the Right Way
Jul 01, 2025
🚫 Stop Copy-Pasting Code! Ever duplicated slug logic or logging across multiple models? Laravel's Traits got your back. 1. What’s a Trait?...
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...
The Difference Between Redux, Context & React Components in State Management
Aug 06, 2025
When building applications with React, there’s always a need to manage data that changes based on user interaction or from fetching external r...