Kritim Yantra
Mar 15, 2025
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:
Let's explore each one in detail.
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!
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:
resources/js
to manage components, layouts, and pages.
.env
file 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.
Laravel 12 continues to refine the Eloquent ORM to streamline database interactions. Although many changes are behind the scenes, you’ll enjoy:
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.
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.
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!
No comments yet. Be the first to comment!
Please log in to post a comment:
Continue with Google