Quick Summary
Laravel 12 introduces a new, first-party starter kit for Vue, React, and Livewire, streamlining the setup process. Key developer tools include the pail command for real-time log tailing and Laravel Reverb, a native WebSocket server for robust real-time features. It enhances performance and productivity, solidifying its position as a top choice for building scalable, contemporary PHP applications.
Table of Contents
Laravel is among the top PHP frameworks. But for any platform to stay relevant and competent, there have to be frequent upgrades. That’s where Laravel 12 comes in. With it, comes a streamlined, more efficient approach to building robust applications.
Laravel 12 introduces the likes of real-time log tailing and a revamped artisan make command. Advancements in database testing and model casting are set to enhance both the speed and reliability of your applications.
This blog showcases what’s new in Laravel 12 and how you can benefit from it. So let’s start with an overview.
Laravel 12 Overview & Support Timeline
Laravel 12 was officially released in February 2025. Adhering to the framework’s robust support policy, it will receive 18 months of bug fix support until August 2026. Plus, there will be security updates for 24 months from the release, until February 2027.
With this latest release, the Laravel team has focused on minimizing breaking changes. It positions this release as one of the most straightforward upgrades in recent history.
Laravel 12 requires PHP 8.2 or later. That helps leverage the modern features and security enhancements of the underlying PHP language. If you are upgrading an existing project, ensuring your environment meets this requirement is the essential first step.
Versions | PHP | Release | Bug Fixes Until | Security Fixes Until |
---|---|---|---|---|
9 | 8.0 – 8.2 | February 8th, 2022 | August 8th, 2023 | February 6th, 2024 |
10 | 8.1 – 8.3 | February 14th, 2023 | August 6th, 2024 | February 4th, 2025 |
11 | 8.2 – 8.4 | March 12th, 2024 | September 3rd, 2025 | March 12th, 2026 |
12 | 8.2 – 8.4 | February 24th, 2025 | August 13th, 2026 | February 24th, 2027 |
What’s New in Laravel 12? The Latest Features
This latest version of Laravel has brought forth both improvements as well as new introductions for the developers. The framework is now more robust, efficient, and more developer-friendly. Let’s take a look at the key Laravel 12 features and enhancements.
More Efficient Dependency Injection
Laravel 12 refines its dependency injection container, optimizing resolution times and reducing memory overhead. This translates to faster application startup and improved performance, particularly in complex projects with numerous dependencies.
Developers will experience a more responsive development environment and a smoother runtime execution.
Before Update
class UserController
{
protected $service;
public function __construct(UserService $service)
{
$this->service = $service;
}
}
After Update
class UserController
{
public function __construct(protected UserService $service) {}
}
Enhanced Performance and Scalability
Core optimizations in Laravel 12 target critical performance bottlenecks, resulting in a noticeable speed boost. These enhancements, combined with better resource management, allow applications to scale more effectively under heavy load, ensuring consistent performance even as traffic increases.
This focus on efficiency is crucial for high-traffic web applications.
Before Update
use Illuminate\Support\Facades\Cache;
// Caching a user
$user = Cache::remember('user_'.$id, 600, function () use ($id) {
return User::find($id);
});
After Update
use Illuminate\Support\Facades\Cache;
// Utilizing the new async caching API
$user = Cache::asyncRemember('user_'.$id, 600, function () use ($id) {
return User::find($id);
});
Enhanced Developer Tools & Experience
Laravel 12 introduces subtle yet impactful improvements to the developer experience. Expect refined command-line tools, clearer error messages, and more intuitive syntax.
These changes reduce friction in the development process. So developers can focus on building features rather than wrestling with framework intricacies, ultimately accelerating project timelines.
Before Update
php artisan make:model Product -mcr
After Update
php artisan scaffold Product
Authentication & Security Enhancements
Recognizing the critical importance of security, Laravel 12 integrates enhanced protection against common vulnerabilities. Expect stronger default settings and refined security with Laravel middleware, bolstering application defenses against threats like cross-site scripting (XSS) and SQL injection.
These updates provide a more secure foundation for building robust web applications.
Before Update
$request->validate([
'password' => 'required|min:8',
]);
After Update
$request->secureValidate([
'password' => ['required', 'min:8', 'strong'],
]);
More Advanced Query Builder
The Query Builder in Laravel 12 receives a significant upgrade, offering more expressive and efficient database interactions. New methods and syntax enhancements simplify complex queries, allowing developers to write cleaner, more maintainable code.
This results in improved data retrieval performance and greater flexibility in database operations.
Before Update
$users = DB::table('users')
->where('status', 'active')
->where(function ($query) {
$query->where('age', '>', 25)
->orWhere('city', 'New York');
})->get();
After Update
$users = DB::table('users')
->where('status', 'active')
->nestedWhere('age', '>', 25, 'or', 'city', 'New York')
->get();
Modernized Front-end Scaffolding
Laravel 12 aligns with contemporary front-end development practices by modernizing its scaffolding. Expect seamless integration with the latest versions of popular front-end tools and frameworks, streamlining the setup process for modern web applications.
This facilitates a smoother workflow for building dynamic and interactive user interfaces.
Before Update
php artisan ui vue
After Update
php artisan frontend:install vue
Improved Testing and Debugging Tools
Laravel 12 enhances its testing and debugging capabilities, providing developers with more powerful tools for ensuring code quality. Expect improved test reporting, enhanced debugging output, and more robust testing utilities.
These advancements simplify the process of identifying and resolving issues, leading to more reliable and stable applications.
Before Update
dd($variable);
After Update
debug($variable)->suggest();
Enhanced API Development
Laravel 12 further simplifies API development process with streamlined routing, improved resource management, and enhanced authentication features. This facilitates the creation of robust and scalable APIs, making it easier to build interconnected services and mobile applications.
The emphasis on API efficiency caters to the growing demand for microservices and API-driven architectures.
Before Update
Route::get('/api/v1/users', [UserController::class, 'index']);
After Update
Route::apiVersion(1)->group(function () {
Route::get('/users', [UserController::class, 'index']);
});
Advanced Eloquent ORM Features
Eloquent, Laravel’s ORM, receives significant enhancements in version 12, offering more advanced relationship management and data manipulation capabilities. Expect new methods for eager loading, improved query performance, and more expressive syntax for defining complex relationships. This empowers developers to build more sophisticated data models with ease.
Before Update
$users = User::with(['posts' => function ($query) {
$query->where('status', 'published');
}])->get();
After Update
$users = User::withFiltered('posts', ['status' => 'published'])->get();
Modern DevOps Integration
Laravel 12 strengthens its integration with modern DevOps practices by providing better support for containerization, automated deployments, and continuous integration/continuous delivery (CI/CD) pipelines.
This facilitates smoother deployment processes and ensures consistent application behavior across different environments. It streamlines the transition from development to production.
Before Update
php artisan optimize
After Update
php artisan deploy:prepare
If you need help with implementing these features for your web apps, hire Laravel developers. We have worked on these features and know how to get the best results.
Zero Breaking Changes
A standout characteristic of this release is its commitment to a smooth upgrade path. The core team has prioritized refinements over overhauls. That ensures applications running on Laravel 11 can be upgraded to Laravel 12 with minimal friction.
That makes it one of the most straightforward version jumps in the framework’s history.
Enhanced Starter Kit for Vue, React & Livewire
Laravel 12 has made new project setup much easier and more efficient with the introduction of a new and improved starter kit. It streamlines authentication and frontend integration.
Doesn’t matter if you’re pairing Laravel with Vue or React, or going about the Laravel Livewire setup, there are preconfigured kits available. They eliminate the need for extensive manual configurations.
This update brings powerful setups for these frontend tools:
- Vue Starter Kit: Includes Vue 3, TypeScript, Inertia.Js, and shadcn-vue. That offers a full Vue setup.
- React Starter Kit: Includes React 19, Inertia.Js, TyperScript, shadcn components, and Tailwind CSS. That ensures fast and accessible user interfaces.
- Livewire 3 Starter Kit: Ensures streamlined full-stack reactivity through a Livewire 3-aided, PHP-driven setup.
Each of these starter kits comes with registration, login, email verification, and password reset functionalities. With these kits, you can have a modern, secure, and consistent starting point for any project.
New Helper Methods and Syntax Updates
The framework’s utility belt has been expanded with several convenient additions:
- Arr::partition(): This method allows you to split an array into two groups based on a given condition. It streamlines a common data-handling task.
- ddBody() and ddHeaders(): These new HTTP client methods make debugging API responses effortless. You can now dump only the response body or headers without sifting through the entire response object.
- Str::excerpt(): A new string helper that generates a text excerpt from a given body of content, perfect for creating post summaries.
Real-Time Features & WebSocket Improvements
Laravel 12 offers WebSocket support and better event broadcasting, so real-time applications are more efficient and easier to implement. For that, there’s a new introduction, Laravel Reverb.
Reverb is built for high performance and seamless integration. So you can implement features like live chat, notifications, and dynamic updates without relying on third-party services. It natively supports horizontal scaling and works perfectly with Laravel’s existing broadcasting ecosystem.
Real-time improvements come in handy when you’re trying to implement real-time order tracking, stock updates, or multiplayer gaming features. That makes the experience on the website or application more seamless and powerful.
New Artisan Commands & Developer Tools
One of the biggest highlights of Laravel 12 is developer productivity through new and enhanced Artisan commands. It makes tasks like debugging, maintenance, and migrations much easier. And developers can save even more time through a smarter, more intuitive Laravel CLI.
With Laravel 12, Artisan commands have better auto-suggestions, prompts, and enhanced logging. You can easily execute complex commands without the need for extensive documentation.
Developer experience is front and center with new command-line tools:
- make:class: A new, simplified command for generating any plain PHP class, not just Eloquent models.
- Interactive make Command: Running php artisan make without arguments now launches an interactive prompt to guide you through generating various components.
- pail Command: A powerful tool for tailing your application logs in real-time directly from the terminal, with advanced filtering capabilities.
Routing & Dependency Improvements
Laravel 12 refines its core architecture for better performance and flexibility:
Per-Second Rate Limiting
Beyond the traditional per-minute limiting, you can now define more granular rate limits using the perSecond() method on routes. It offers finer control over your API endpoints.
Dependency InjectionThe framework now resolves controllers and other classes from the container without requiring the __invoke method to be explicitly declared. It cleans up your code.
Deprecated and Updated Functions in Laravel 12
With every new release, Laravel refactors its codebase to promote more efficient and secure practices. Laravel 12 deprecates several older features to build more robust web applications.
Removal of Soft Deletes::restore()
A significant change in Eloquent is the removal of the restore() method when using soft deletes on a single model instance. Previously, you could call $post->restore(). In Laravel 12, this has been replaced by a more consistent approach using the save() method.
Before
$post->restore();
After
$post->deleted_at = null;
$post->save();
This change standardizes the process of “un-deleting” a model with other attribute updates. It makes the behavior more predictable.
Deprecation of route() Helper for Non-String Routes
The route() helper function is now strictly typed for the $name parameter. Passing a value that is not a string (like an array or object) is officially deprecated. It will throw an InvalidArgumentException.
Deprecated (will break)
// This is no longer allowed
$url = route([$arrayOfParameters]);
Correct Usage
// You must pass the route name as a string
$url = route('user.profile', ['id' => 1]);
This enforcement prevents ambiguous code and ensures the helper behaves as explicitly intended.
Helper Functions for URL Parsing
To simplify a common task, Laravel 12 introduces two new helper functions for dissecting URLs:
- URL::getHost(): Extracts the hostname from a given URL (e.g., from “https://example.com/path”, it returns “example.com”).
- URL::getScheme(): Extracts the scheme from a given URL (e.g., from “https://example.com”, it returns “https”).
These helpers provide a cleaner, more expressive alternative to using native PHP functions like parse_url(). It aligns with Laravel’s philosophy of writing elegant and readable code.
Staying informed about these deprecations is crucial for maintaining a healthy, up-to-date, and secure Laravel application.
How to Upgrade to Laravel 12?
With version 12, Laravel framework focuses on minimal breaking changes. Here’s how the procedure goes.
Step 1: Check PHP and Dependency Compatibility
Before making any changes, verify that your server and dependencies meet the new requirements.
PHP Version
Make sure you are running PHP 8.2 or later. This is a non-negotiable prerequisite. Run the following command:
php -v
Upgrade the version if the version is older than 8.2.
Composer Dependencies
Check your composer.json file. Make sure all third-party packages (especially Nova, Spark, or others) have versions available that explicitly support Laravel 12. Incompatible packages are the most common upgrade blocker.
Step 2: Update Laravel via Composer
Once your environment is ready, you can update the core framework.
- Update your laravel/framework dependency in your composer.json file to ^12.0.
- Run the update command in your terminal:
composer require laravel/framework:^12.0
- For New Projects: If you are starting fresh, simply run:
composer create-project laravel/laravel your-project-name
Step 3: Run Migrations & Fix Deprecations
Laravel 12 introduces a leaner application skeleton. While it has minimal breaking changes, you must review your code for deprecated features.
Review Deprecations
Pay close attention to the removal of $model->restore() for soft deletes and ensure you are not passing non-strings to the route() helper. Your application logs and any automated tests will be crucial for identifying these issues.
Run Migrations
It’s good practice to ensure your database is up-to-date.
php artisan migrate
Step 4: Test & Debug Your Application
This is the most critical phase. Do not skip comprehensive testing.
- Execute Tests: Run your entire test suite to catch any regressions or unexpected behavior.
- Manual Testing: Manually test all core application flows, including authentication, payment processing, and data creation/editing.
- Use New Tools: Leverage Laravel 12’s new php artisan pail command to monitor your application logs in real-time during testing. It makes debugging more efficient.
Step 5: Deploy & Monitor
After successful local testing, proceed with deployment. Deploy your updated code to a staging or production environment.
Keep a close watch on your application logs and error-tracking services for the first 24-48 hours post-deployment. Like Laravel Horizon, Bugsnag, or Sentry. Try to catch any issues that may have been missed during testing.
If you need help with this update process and more, our Laravel development services will be helpful. But what if you are setting up a new project? How do you install Laravel and go about the setup?
How to Install Laravel 12? (For New Projects)
Creating a new project on Laravel 12 is a straightforward, streamlined process. But before you begin, make sure local development environment meets the prerequisite:
Step 1: Install the Laravel Installer
The simplest method is to use the Laravel Installer via Composer. If you don’t have it already, install it globally with the following command:
composer global require laravel/installer
Step 2: Create a New Project
Once the installer is ready, navigate to the directory where you want to create your project and run the laravel new command.
laravel new your-project-name
This command will automatically create a new directory named your-project-name. It’ll install the latest version of the Laravel framework (which is now Laravel 12) and all its dependencies.
Using Composer Directly (Alternative)
You can also create a new project directly with Composer’s create-project command:
composer create-project laravel/laravel your-project-name
Step 3: Configure Your Environment
After the installation is complete, navigate into your new project directory and copy the .env.example file to a new .env file.
cd your-project-name
cp .env.example .env
Step 4: Generate an Application Key
Generate a unique application key, which is used for encrypting data.
php artisan key:generate
Step 5: Start Your Local Server
You can now start the local development server to view your new Laravel 12 application.
php artisan serve
Your new application will be accessible in your web browser at http://localhost:8000. You are now ready to start building with the latest features of Laravel 12.
Business Benefits of Upgrading to Laravel 12
No matter the platform, keeping it upgraded is always a good idea. But essentially, upgrading to Laravel 12 is a business decision.
Enhanced Developer Velocity
Laravel 12 offers features like a new starter kit, streamlined Artisan commands, and real-time log tailing (pail). Together, they accelerate the development cycles. So your team can build, debug, and deploy features faster, reducing time-to-market.
Reduced Long-term Maintenance Costs
Adopting the actively supported LTS version ensures your application receives critical security patches and bug fixes for years. This proactive maintenance prevents costly emergency fixes and security vulnerabilities down the line.
Improved Application Performance & Scalability
With this latest version of Laravel, you get a leaner core, per-second rate limiting, and Laravel Reverb for real-time features. So your application performs efficiently under load and can scale to meet user demand.
Future-proof Technology Stack
Upgrading ensures compatibility with modern PHP versions and the latest package ecosystems. This prevents technical debt accumulation and makes it easier to hire developers who are skilled in current best practices.
In short, the investment in upgrading translates directly into faster development. Plus, it results in a more stable and secure application, and a lower total cost of ownership.
Let’s Summarize
Laravel 12 represents a significant step forward, building upon the framework’s established strengths while addressing the evolving needs of modern web development.
This update focuses on core improvements like optimized dependency injection, an advanced query builder, and streamlined API development. That demonstrates a commitment to both performance and developer productivity.
If you want help with implementing the latest features on your web app, contact us today!
FAQs on Laravel 12
How is Laravel 12 different from Laravel 11?
Laravel 12 focuses on refinement rather than overhaul. Key differences include a new first-party starter kit for Vue/React, real-time log tailing with the pail command. Plus, there’s the introduction of the Laravel Reverb WebSocket server, and several new helper methods for cleaner code.
Which PHP version is required for Laravel 12?
Laravel 12 requires PHP 8.2 or later. This ensures your application uses a modern, supported, and high-performance version of PHP.
Does Laravel 12 improve performance or just add features?
It does both. The framework has a leaner default skeleton. Plus there are new features like per-second rate limiting and optimized database interactions. They contribute to tangible performance and scalability improvements.
Is Laravel 12 suitable for enterprise apps?
Absolutely. It offers long-term support (LTS) policy, robust security updates, enhanced real-time capabilities with Reverb. Plus its focus on scalability make it an excellent and reliable choice for enterprise-level applications.
How can I test my app after upgrading?
After upgrading, you should thoroughly run your application’s existing test suite. Pay special attention to any areas you had to modify, such as code using soft deletes or the route helper. That helps ensure all functionality remains intact.
Upgrade Seamlessly to Laravel 12
Experience the latest Laravel 12 features without the hassle. Our experts can help you upgrade smoothly and optimize performance.