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
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...
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...
Using useCallback in React: Benefits, Limitations, Best Practices
Jul 31, 2025
The useCallback hook in React is used to return a memoized version of a callback function, so it's only recreated when its dependencies change. The...
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(...
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...
Top Laravel & PHP Updates for Cleaner, Faster Code
Aug 17, 2025
Laravel Global Scopes: Automatic Query Filtering Eloquent Importance: Enforce consistent filters across all model queries (e.g., Soft Del...