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
Using Web Components the Smart Way
Jul 06, 2025
Using Web Components the Smart Way A lot of developers assume Web Components are meant to replace full SPA frameworks like React or Vue. But in rea...
Laravel 12.21.0 – A Smart Update for Cleaner Queries and Stricter Validation
Aug 03, 2025
Laravel 12.21.0 introduces two game-changing features aimed at writing cleaner, more maintainable code. The update includes the new whereValueBetwe...
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...
CSS Specificity: Layers vs BEM vs Utility Classes
Jun 26, 2025
CSS Specificity: Cascade Layers vs BEM vs Utility Classes This article compares three approaches to managing CSS specificity — BEM, utility‑f...
Bypassing $fillable Safely with forceFill() in Laravel
Jul 02, 2025
Bypassing $fillable Safely with forceFill() in Laravel Ever used create() in Laravel and noticed some fields like role or status didn’t save? T...
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?...