By Shivani Makwanaauthor-imgBy Akshay Maradiyaauthor-img
May 13, 2025|11 Minute read|
Play
/ / Exploring Laravel 12: New Features and Upgrade Guide
At a Glance:

Laravel is one of the most popular frameworks in PHP server-side scripting language. Recently, Laravel 12 was released with a set of updates and focuses on speed, security, and new starter kits for Vue, React, and Livewire. It also introduces slick API features like GraphQL support and improved WebSocket tools for real-time apps. Upgrading is simple, stick with us to upgrade to the latest version of Laravel 12.  

Introduction

Laravel is a go-to choice for programmers who want to build fast, secure, and up-to-date web projects. The latest launch of Laravel 12 brings several advancements in performance, app architecture, and developer experience. The newest release opens the door for modern PHP development while maintaining the core value of the framework.

We are back with an in-depth guide to help you seamlessly integrate Laravel 12 within your project. This blog discusses all the new features, performance enhancements, and easy steps to help you upgrade to Laravel 12. Let’s first look at the recent version and support details.

Laravel 12 Support Timeline & Policy

Every Laravel version comes with 18 months of updates and bug fixes, plus an additional 6 months of security patches, giving you 2 years of total security support.

Below is a breakdown of the latest version, support details, and information about the upcoming release.

Versions of Laravel

What Are the New Key Features of Laravel 12?

Laravel 12 was released on February 24, 2025! The core team has made some great updates to make developers' work easier and the framework even stronger. It’s out now and ready to use. Let’s take a look at what’s new and what’s got everyone talking!

New Starter Kit for Vue, React & Livewire

Laravel’s starter kits have always made starting projects easier, but v12 takes it a step further with powerful setups designed for today’s top front-end tools:

  • React Starter Kit: Includes Inertia.js, React 19, TypeScript, Tailwind CSS, and shadcn components, offering fast, polished, and accessible interfaces.

  • Vue Starter Kit: Comes with Inertia.js, Vue 3, TypeScript, and shadcn-vue, giving you a fully ready Vue foundation.

  • Livewire 3 Starter Kit: A PHP-driven setup with Livewire 3 (for smooth full-stack reactivity), TypeScript, Tailwind, and Flux UI components for a seamless experience.

Each kit is ready with key features like login, registration, password reset, and email verification. Plus, there's an optional WorkOS AuthKit for advanced features like SSO, passkeys, and social logins. Developers can now build secure, cutting-edge apps quickly, skipping the usual setup hassle.

New ddBody() Method

Adds a small but super handy feature for testing: the ddBody() method on the TestResponse class. Contributed by Sam Carré, this method helps you quickly dump the response body while writing feature tests—making debugging test failures much easier.

Instead of digging through the full response manually, you can now inspect the entire body or even a specific key with just one line.



$response = $this->get('/example');

// Dump the full response body
$response->ddBody();

// Dump a specific JSON key
$response->ddJson('title'); // Behind the scenes: uses $this->ddJson('title')

New Arr::partition() Helper

Introduces a new partition() method to the Arr helper, thanks to a contribution from Liam Duckett. This method lets you split an array into two parts based on a condition, just like the partition() method on collections, but now without needing to convert to a collection. 

It’s a small addition, but super useful when you want to keep things lightweight.



$numbers = [0, 1, 2, 3, 4, 5];

// With collections
[$evens, $odds] = collect($numbers)->partition(fn($n) => $n % 2 === 0);

// Now with arrays
[$evens, $odds] = Arr::partition($numbers, fn($n) => $n % 2 === 0);

JSON Unicode Cast Type

A new json:unicode cast type for Eloquent attributes, contributed by @fuwasegu, enables JSON encoding with JSON_UNESCAPED_UNICODE. This game-changer for applications handling non-ASCII characters like Japanese, Chinese, or emojis, as it avoids escaping Unicode characters into \\uXXXX format.


protected $casts = [
    'data' => 'json:unicode',
];

Eloquent’s default json cast escaped Unicode characters, making JSON-encoded attributes less human-readable and often requiring manual decoding. This new cast simplifies storing and retrieving JSON data, eliminating the need for custom accessors or manual json_encode() calls.

Add "Storage Linked" Check to the About Command

Thanks to Adam Patterson, the artisan about command now includes a section showing the status of filesystem links defined in the filesystem.php configuration. This makes it easier to verify whether storage links are correctly set up.

For example, with the following configuration:



// config/filesystem.php
return [
    'links' => [
        public_path('storage') => storage_path('app/public'),
        public_path('images') => storage_path('app/images'),
    ],
];

Running php artisan about will display:

Storage
public/images ................................................... NOT LINKED
public/storage .................................................. LINKED

This addition saves time when troubleshooting storage-related issues, ensuring your links are properly configured.

Model except() Method

Vishal Chavda contributed the new Model::except() method, which allows you to retrieve model attributes while excluding specific keys. This method serves as the inverse of the only() method, providing a clean way to filter out unwanted attributes.

For example, with the following configuration:



$user->except(['id', 'email']);

This is particularly useful when you need to share or process a subset of model data without sensitive or unnecessary fields, streamlining data handling in APIs or views.

Allow Merging Model Attributes Before Insert

Luke Kuzmish introduced the fillAndInsert() method, which enables merging and processing model attributes before insertion. This is ideal for scenarios where you must cast values to primitives, set timestamps, or generate UUIDs.



ModelWithUniqueStringIds::fillAndInsert([
    [
        'name' => 'Taylor',
        'role' => IntBackedRole::Admin,
        'role_string' => StringBackedRole::Admin,
    ],
    [
        'name' => 'Nuno',
        'role' => 3,
        'role_string' => 'admin',
    ],
    [
        'name' => 'Dries',
        'uuid' => 'bbbb0000-0000-7000-0000-000000000000',
    ],
    [
        'name' => 'Chris',
    ],
]);

This method simplifies bulk inserts with custom attribute handling, making it easier to maintain consistency in your data.

Add HTTP Request Exception

Luke Kuzmish also contributed a requestException() method to the HTTP client, simplifying the process of stubbing exceptions for testing. This method provides a cleaner way to create mock HTTP exceptions compared to the previous features of Laravel 11.27.



// Before
$exception = new RequestException(
    new Response(
        Http::response(['code' => 'not_found'], 404)->wait()
    )
);

// After
$exception = Http::requestException(['code' => 'not_found'], 404);

This improvement makes HTTP client testing more intuitive and less error prone.

URI Path Segments Helper Method

Chester Sykes added a pathSegments() method to the Uri class, which returns the URI path as a collection of segments. This makes it easier to work with URL paths programmatically.



$uri = Uri::of('https://laravel.com/one/two/three');

// Manually
$firstSegment = collect(explode('/', $uri->path()))->first(); // 'one'

// Using the pathSegments() method
$firstSegment = $uri->pathSegments()->first(); // 'one'

This method streamlines URL parsing, especially for routing or navigation logic, by providing a convenient collection-based interface.

Eloquent whereAttachedTo() Query Builder Method

Jacob Baker-Kretzmar contributed the whereAttachedTo () method to the Eloquent query builder. 



$tags = Tag::where('created_at', now()->subMonth())->get();

// Before
$taggedPosts = Post::whereHas('tags', function ($query) use ($tags) {
    $query->whereKey($tags);
})->get();

// After
$taggedPosts = Post::whereAttachedTo($tags)->get();

// After with explicit relationship name
$taggedPosts = Post::whereAttachedTo($tags, 'tags')->get();

This addition reduces boilerplate code and improves readability when working with many-to-many relationships, making it a valuable tool for developers handling complex data models.

Enhancements: Performance Scalability

Laravel 12 focuses heavily on speed and scalability, packing in optimizations that help your apps stay fast, even under heavy load. Whether you're building a high-traffic site or scaling an existing app, these updates make a noticeable difference.

One of the standout improvements is asynchronous caching. In earlier versions, cache operations were synchronous, which could slow things down when traffic spiked. Now, Laravel handles frequent cache calls more efficiently, reducing wait times and improving response speed.

What Else Got Faster?

  • Improved database queries with smarter indexing and execution strategies.

  • Faster background job processing, so queues don’t pile up.

  • Better memory management helps your app stay responsive during traffic surges.

These performance upgrades make Laravel 12 a solid choice for building anything from fast-loading storefronts to real-time dashboards and high-scale SaaS platforms.

Why Upgrade to Laravel 12?

Laravel 12 upgrade is not about keeping up—it's about providing your projects with a framework that is faster, secure, and suited for the web demands of the present. Whatever you're building, whether a personal site or a high-profile application, Laravel 12 delivers actual upgrades to make development faster and more reliable. Here are the reasons why you should upgrade to Laravel 12:

  • Lightning-Fast Performance: With asynchronous caching, smarter database queries, and rapid job processing, Laravel 12 has your apps loading in real-time, even under heavy traffic.

  • First-Class Security: Enhanced authentication, secure data validation, and enhanced API protection keep your projects safe from threats today.

  • Built to Scale: Enhanced memory management and native support for real-time features like WebSocket's make Laravel 12 perfect for scaling applications, from small businesses to active platforms.

  • Future-PHP: Enhanced features like GraphQL support, API versioning, and integrated Vue and React starter kits make Laravel 12 a smart choice for new-generation, cutting-edge applications.

Whether building a live chat system, an online shopping cart, or an advanced SaaS application, Laravel 12 equips you with the tools to build stable, secure, and scalable applications that last.

How to Upgrade to Laravel 12?

The easiest way to upgrade is with Laravel Shift, but you can also follow the official Laravel 12 upgrade guide if you prefer doing it yourself.

The upgrade from Laravel version 11 to Laravel 12 is easy and simple but requires potential tests to ensure the smooth transition. It helps you perform the upgrade through Laravel Shift, or you can follow the upgrade guide from Laravel's official documentation. It is very helpful to upgrade manually and also gives you a step-by-step plan for upgrading to Laravel 12.

Check Your PHP Version

Laravel 12 requires PHP 8.2 or higher. To find out the PHP version on your server, run the command:

php -v

If it is older than 8.2, you must upgrade your PHP version following the package manager instructions for your server or hosting.

Update Dependencies via Composer

To pull in Laravel 12 and its dependencies, run the below command from your project root directory:

composer require laravel/framework:^12.0

This will thus update your project to the latest release of Laravel 12 while keeping all of the dependencies intact.

Run Database Migration

Laravel 12 might include some new database schema changes. So after the update, run the migrations to bring your database into sync: 

php artisan migrate

To see the changes without performing them, run: 

php artisan migrate-- pretend

Validate Thoroughly 

Before going to production (live), check that all checks are running and working as expected with Laravel 12. The Laravel validation process includes verifying data to avoid mistakes or security threats.  

  • Check all routes, middleware, and authentication flows. 

  • Run the test suite to capture any issues. 

  • Confirm database queries and run correctly with the new optimizations. 

Laravel provides some debugging methods like dd(), dump(), and logs in case you run into testing problems. 

Rollout and Monitor 

You can proceed with live production rollout when the app is successfully tested in development. After deployment, monitor logs and performance metrics to check if faster load times and query execution are working well. 

Conclusion: Start Using Laravel 12 

Laravel 12 makes some significant improvements to the core features of the framework, like: 

  • It improves performance; 

  • It increases security; 

  • It includes more innovative debugging features, and 

  • It enhances real-time capabilities. 

These improvements give web developers the tools to build modern, high-performing web applications. Stay updated with the latest updates and improvements to make the most out of the Laravel framework.  

Looking to migrate your current project to Laravel 12? Lucent Innovation is a trusted partner to Hire Laravel developers who can help you with smooth migration and build tailored solutions per your needs. Focus on your core business and let Laravel web gurus create your apps. 

Shivani Makwana

Akshay Maradiya

Software Developer

One-stop solution for next-gen tech.

Frequently Asked Questions

Still have Questions?

Let’s Talk

When was Laravel 12 released?

arrow

Which PHP version is required for Laravel 12?

arrow

What is the difference between Laravel 11 and 12?

arrow