Laravel 12 New Features And Updates
Laravel 12 is finally here, bringing exciting improvements that boost productivity without breaking existing applications. In this release, you’ll notice new commands, modern starter kits built with React, Vue, and Livewire, improved Eloquent ORM features, and quality‐of‐life enhancements such as a new request merging method and a more secure image validation rule.
In this post, we’ll dive into:
- A new command: composer run dev
- Modern starter kits with WorkOS AuthKit Integration
- New and improved Eloquent ORM features
- The handy mergeIfMissing method with dot notation
- An image validation rule change to boost security
Let's explore each one in detail.
New Command: composer run dev
Laravel 12 streamlines your local development workflow. After creating a new application, instead of juggling multiple commands to run your development server and asset bundler, you can now simply run:
cd my-app
npm install && npm run build
composer run dev
The composer run dev command not only boots up the Laravel development server but also ensures that Vite (or your chosen bundler) starts automatically. This means fewer steps to get your application up and running!
Modern Starter Kits & WorkOS AuthKit Integration
Laravel’s new starter kits replace the older Breeze and Jetstream packages. These kits provide a modern foundation for building full-stack applications out-of-the-box. Here’s what’s new:
-
React & Vue Starter Kits:
Built on Inertia 2, TypeScript, Tailwind CSS, and
shadcn/ui, these kits help you build responsive single-page applications using your favorite JavaScript framework.
Example: The React kit includes a complete directory structure in
resources/jsto manage components, layouts, and pages. - Livewire Starter Kit: Powered by Flux UI and Laravel Volt, this kit is ideal if you prefer building interactive UIs with minimal JavaScript by leveraging Livewire.
-
WorkOS AuthKit Integration:
All starter kits now include a variant powered by WorkOS AuthKit. This integration offers:
- Social authentication (Google, Microsoft, GitHub, and Apple)
- Passkey authentication
- Email “Magic Auth”
- Single Sign-On (SSO)
.envfile with:
WORKOS_CLIENT_ID=your-client-id
WORKOS_API_KEY=your-api-key
WORKOS_REDIRECT_URL="${APP_URL}/authenticate"
These modern starter kits give you a head start with robust authentication scaffolding and a fully customizable frontend—all in one codebase.
Eloquent ORM Enhancements
Laravel 12 continues to refine the Eloquent ORM to streamline database interactions. Although many changes are behind the scenes, you’ll enjoy:
- Improved Relationship Handling: Eloquent now offers more intuitive ways to work with relationships and query scopes, making your queries cleaner and more expressive.
- Enhanced Lazy Loading Prevention: With improved safeguards, your application’s performance and debugging experience are smoother than ever.
New Request Handling: mergeIfMissing with Dot Notation
Managing request data just got easier. Laravel 12 introduces the mergeIfMissing method, which allows you to merge default values into your request’s input data—especially useful for nested arrays using dot notation.
For example, to ensure a default theme value is set if missing:
// Merge a default theme value if not provided in the request
$request->mergeIfMissing([
'settings.theme' => 'light',
]);
// Later in your controller, you can access:
$theme = $request->input('settings.theme'); // will be 'light' if missing
This method simplifies your code and prevents repetitive checks.
Image Validation Rule Change for Enhanced Security
In Laravel 12, the built-in image validation rule has been updated to exclude SVG files by default for enhanced security. SVG images can sometimes pose risks, so this change protects your application.
For example, validating an image upload:
$request->validate([
'avatar' => 'image', // Now rejects SVGs by default
]);
To allow SVG uploads, update the rules explicitly:
$request->validate([
'avatar' => 'image|mimes:jpg,jpeg,png,svg',
]);
This change encourages deliberate decisions about accepting SVGs and keeps your application more secure by default.
Conclusion
Laravel 12 is a thoughtful release designed to keep your applications modern and secure while providing an excellent developer experience. With the new composer run dev command, modern starter kits (including WorkOS AuthKit integration), subtle yet powerful Eloquent ORM improvements, and enhanced request handling and validation rules, Laravel 12 sets a solid foundation for building scalable and robust applications.
Whether you're starting a new project or upgrading an existing one, these updates help you build faster and smarter. Dive in and explore all that Laravel 12 has to offer!
Projects to explore next
Source-code projects from the KritiMyantra catalogue. Check each project's details before buying.
Flask Authentication System (Free Version) - Kritim Yantra
🛠 Features✔ Google & GitHub Authentication✔ User Registration & Login✔ Profile/Dashboard Access✔ Secure & Mi...
Flask Blog CMS with Admin Dashboard — Python Source Code
A Flask-based blogging website with a built-in admin dashboard. Manage articles, images, categories, tags and featured p...
Laravel 12 + ReactJS Starter Kit: Add Multi-Language Support (Arabic, English, Spanish) with Blog CRUD
🚀 Installation & Setup Download & Extract Get the ZIP from kritimyantra.com and extract it. Includes preconfigu...
Comments
No comments yet. Be the first to comment.
Sign in to join the discussion.