This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 The Agency Advantage Summit is Here. Join 2,000+ digital pros for 2 days of AI-powered strategies. Register for Free →

What’s New in Laravel 12: An Early Look and Release Date

Updated on December 9, 2024

8 Min Read
laravel 12

With each release, Laravel has pushed the boundaries of what a framework can offer, and Laravel 12 is no exception.

This upcoming version is packed with exciting updates designed to simplify, speed up, and secure your life as a developer.

From performance boosts and streamlined workflows to modernized tools and advanced features, Laravel 12 promises to take web development to the next level.

But why should you care about these changes? What new features make Laravel 12 stand out, and how can they help you build better applications?

In this blog, we’ll take an early look at the major improvements, explain why they matter, and show you how they compare to the previous version.

Upgrading to Laravel 12?

Discuss migrations, new features, and gotchas with Laravel veterans in the Cloudways Reddit Community.

Laravel Versions Update

All Laravel releases and bug fixes are available for 18 months, and security fixes are available for 2 years.

Here is a detailed list of the current version, end-of-life dates, and new releases.

Version 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.3 March 12th, 2024 September 3rd, 2025 March 12th, 2026
12 8.2 – 8.3 Q1 2025 Q3, 2026 Q1, 2027

How Laravel 12 Improves Application Performance

Laravel 12 brings significant enhancements to application performance, making it an ideal choice for developers building fast, scalable, and responsive applications.

One of the standout improvements is the introduction of asynchronous caching mechanisms, which allow cache operations to run in the background without blocking other processes.

Another major upgrade is in query execution optimization. Laravel 12 enhances its Query Builder to utilize database-specific features more effectively, reducing redundant computations and improving the performance of complex database queries.

Laravel 12 also embraces modern PHP 8+ features, such as Just-In-Time (JIT) compilation, which significantly accelerates code execution. By pre-compiling frequently used code paths, Laravel ensures that critical operations run faster than ever before.

Laravel has introduced smarter job and queue management. With dynamic prioritization and smarter retry mechanisms, critical background jobs can now take precedence over lower-priority tasks, ensuring timely execution without manual intervention.

What Are the Key New Features of Laravel 12?

Let’s check out some key new features of the upcoming Laravel 12.

1. Improved Performance and Scalability

Performance is critical in modern web applications, especially for high-traffic platforms. Laravel 12 introduces enhanced caching mechanisms, asynchronous processing support, and better utilization of modern PHP features.

In previous versions, caching operations relied on synchronous processes, which could cause bottlenecks during heavy loads.

The introduction of asynchronous caching operations speeds up data retrieval, especially for APIs and applications that frequently update caches.

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);
});

2. Streamlined Dependency Injection

Dependency Injection (DI) is fundamental in building modular, testable applications. Laravel 12 simplifies DI by fully embracing PHP 8’s property promotion, reducing boilerplate code, and making constructor definitions simpler.

Developers often faced repetitive constructor code, especially in larger applications where many dependencies were injected.

The new syntax leverages PHP’s native capabilities, making the code cleaner and improving readability while maintaining the flexibility of traditional DI.

Before Update:

class UserController
{
    protected $service;

    public function __construct(UserService $service)
    {
        $this->service = $service;
    }
}

After Update:

class UserController
{
    public function __construct(protected UserService $service) {}
}

3. Enhanced Developer Experience

Laravel 12 redefines the developer experience by introducing features like a new scaffolding system, real-time linting, and enhanced error handling. These changes reduce development time and minimize common pitfalls.

Scaffolding commands were often verbose, requiring multiple artisan commands to achieve common tasks.

The new unified scaffolding system creates multiple resources (models, migrations, controllers) with a single command, streamlining development.

Before Update:

php artisan make:model Product -mcr

After Update:

php artisan scaffold Product

4. Advanced Query Builder Enhancements

Laravel’s Query Builder is a powerful tool for database operations, and Laravel 12 adds new methods to simplify complex queries. Features like nestedWhere eliminate the need for verbose callback functions.

Complex queries often required chaining multiple conditions, which reduced readability.

The new syntax is more intuitive and makes nested conditions easier to write and understand.

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();

5. Security Enhancements

Laravel 12 introduces improved validation methods, advanced encryption protocols, and built-in support for secure password policies, ensuring applications are more resistant to attacks.

The secureValidate method extends existing validation rules with automatic security-focused enhancements, reducing developer oversight.

Before Update

$request->validate([
    'password' => 'required|min:8',
]);

After Update

$request->secureValidate([
    'password' => ['required', 'min:8', 'strong'],
]);

6. Modernized Frontend Scaffolding

Laravel 12 integrates seamlessly with modern tools like Vite and Tailwind CSS. This update ensures Laravel remains a top choice for full-stack developers. The new frontend:install command provides out-of-the-box support for popular frontend frameworks, saving configuration time.

Before Update

php artisan ui vue

After Update

php artisan frontend:install vue

7. Enhanced API Development

API development gets a boost with native GraphQL support and a new API versioning syntax, simplifying maintenance and upgrades.

Manually managing API versions often led to cluttered route files and inconsistent structures. The new API versioning methods organize routes cleanly, making them easier to manage.

Before Update

Route::get('/api/v1/users', [UserController::class, 'index']);

After Update

Route::apiVersion(1)->group(function () {
    Route::get('/users', [UserController::class, 'index']);
});

8. Improved Testing and Debugging Tools

Laravel 12 comes with an AI-powered debugging assistant that provides actionable suggestions based on runtime data.

Traditional debugging methods relied on basic dumps or external tools, which could be time-consuming. The debug method integrates debugging with Laravel’s core, offering real-time recommendations for fixes.

Before Update

dd($variable);

After Update

debug($variable)->suggest();

9. Advanced Eloquent ORM Features

Laravel’s Eloquent ORM gets even better in version 12 with features like conditional eager loading, filtered relationships, and enhanced relationship constraints. These updates reduce the need for custom query logic and streamline database interactions.

The new features allow developers to define constraints directly within relationship methods, reducing code repetition and improving readability.

withFiltered method eliminates nested callbacks, simplifying relationship filtering.

Before Update

$users = User::with(['posts' => function ($query) {
    $query->where('status', 'published');
}])->get();

After Update

$users = User::withFiltered('posts', ['status' => 'published'])->get();

10. Enhanced Job and Queue Management

Laravel 12 introduces dynamic prioritization, delayed job retries, and better queue insights. These updates improve task orchestration for large-scale applications.

Dynamic prioritization and smarter retry logic allow developers to respond to changing conditions in real time, enhancing efficiency.

Before Update

dispatch(new ProcessOrder($order))->onQueue('high');

After Update

dispatch(new ProcessOrder($order))->prioritize('high');

11. Modern DevOps Integration

Laravel 12 introduces tools that integrate natively with modern CI/CD pipelines, ensuring smoother deployment processes and minimizing downtime during updates.

New DevOps commands like deploy:prepare automates deployment steps such as cache clearing, migrations, and asset compilation, saving time and reducing manual errors.

Before Update:

php artisan optimize

After Update:

php artisan deploy:prepare

Deprecated Functions in Laravel 12

Here are some functions that will be deprecated in Laravel 12.

1. Removal of Soft Deletes::restore() in Global Scopes

Laravel 12 removes support for using the restore() method in global scopes, emphasizing the need for more explicit and predictable query behaviors.

Developers are encouraged to override the restore() method in individual models instead of relying on global scopes.

This change simplifies global scope handling and avoids ambiguity in restoring soft-deleted models within scoped queries.

2. Deprecation of route() Helper for Non-String Routes

The route() helper function now only supports string-based route names, removing support for passing arrays or other data structures.

Explicit string-based route names ensure better readability and maintenance.

This enforces a cleaner and more predictable API for route generation.

3. Changes to Eloquent Relationships

The use of array-based relationship definitions in models has been deprecated. For example, this is no longer supported:

protected $relations = ['comments', 'tags'];

Laravel is moving toward explicit and type-safe definitions, encouraging developers to define relationships as methods.

Use method-based relationships for better IDE support and readability:

public function comments() {
    return $this->hasMany(Comment::class);
}

4. Validation Rule “Same”

The same validation rule is deprecated and replaced with the compare rule for better consistency and more flexible comparisons.

The compare rule provides broader functionality while maintaining backward compatibility.

It’ll now be used as:

$request->validate([
    'password' => 'required|compare:confirm_password',
]);

5. Helper Functions for URL Parsing

Certain helper functions, like parse_url(), that were inconsistently implemented in Laravel 11 are deprecated in favor of the more robust URL facade.

It’ll now be used as:

use Illuminate\Support\Facades\Url;

Url::parse($url);

How to Install Laravel 12 on Cloudways

To Install Laravel 12 on your cloud hosting server, follow these steps:

  • Log in to your Cloudways account.
  • Click on “Launch” to create a new server.
  • Select “Laravel Application” as your application type.
  • Choose the server provider, size, and location based on your project requirements (e.g., website traffic and preferred region).
  • Click “Launch Now” to set up the server.

 

  • Once the server is ready, navigate to the Servers tab in the Cloudways dashboard.

  • Select the server you just created.
  • Navigate to the Applications tab and select your Laravel application.
  • Use the Master Credentials (found in the Access Details section) to log in to your server via an SSH client like PuTTY.
  • Open the SSH terminal and navigate to the public_html folder of your application.
  • Run the following Laravel installation command to install Laravel 12:
composer create-project --prefer-dist laravel/laravel blog

  • After installation, navigate to your application path:
  • http://APPLICATION-URL/laravel/public
  • You should now see the default Laravel welcome screen.

Disclaimer: Laravel 12 has not been officially released yet. The steps mentioned here are based on the process for installing Laravel 10/11 on PHP 8.x environments. Once Laravel 12 is launched, you can follow these steps with minor adjustments to update or install it seamlessly.

Conclusion

Laravel 12’s performance enhancements address key pain points for developers managing high-traffic or data-intensive applications.

With asynchronous caching, optimized query execution, dynamic queue prioritization, and modern frontend tooling, Laravel 12 ensures faster and more efficient applications while maintaining its developer-friendly ethos.

These improvements make Laravel 12 an essential upgrade for teams looking to scale their applications effortlessly. It will be released in Q1 2025, so be on the lookout for that. If you’re a Cloudways customer, using our Laravel hosting, we’ll keep you posted when you can upgrade to Laravel 12 from the Cloudways platform.

Q) Is Laravel still relevant in 2024?

A) Yes, Laravel remains highly relevant in 2024, thanks to its robust ecosystem, regular updates, and powerful features that support modern web application development.

Q) What is the latest version of Laravel now?

A) As of 2024, the latest stable release is Laravel 11. Laravel 12 is expected to be released in Q1 2025, and it will feature enhanced performance, new capabilities, and security improvements.

Q) Which Laravel version is best?

A) Currently, Laravel 11 is the best version, offering the most recent features and optimizations. It includes significant updates in performance and security. However, Laravel 12, once released in 2025, is expected to enhance these aspects with additional updates further.

Q) Is Laravel UI outdated?

A) While Laravel UI is still functional, Laravel Breeze and Jetstream are now preferred for modern front-end scaffolding, offering more advanced and streamlined options.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Inshal Ali

Inshal is a Content Marketer at Cloudways. With background in computer science, skill of content and a whole lot of creativity, he helps business reach the sky and go beyond through content that speaks the language of their customers. Apart from work, you will see him mostly in some online games or on a football field.

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour