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
Essential React Native UI & Interaction Components
Jul 01, 2025
Essential React Native UI & Interaction Components React Native provides a powerful set of built-in components for creating native mobile apps....
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...
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...
Is Laravel Slow? Optimize Queries & Indexes for Maximum Performance
Jul 20, 2025
A detailed, example-rich guide to avoid slowdowns in Laravel apps by optimizing data retrieval and employing indexing smartly. 1. 🧠 Fetch Only...
How OAuth Works
Jun 29, 2025
How OAuth Works OAuth is a protocol that allows third-party applications to access user data without sharing passwords. It's the backbone of secure a...
Supercharge Your PHP Enums with archtechx/enums
Jul 01, 2025
Supercharge Your PHP Enums with archtechx/enums PHP 8.1 introduced native enums—type‑safe sets of named values like statuses or roles. The arch...
