DEV Community

Cover image for Laravel 12 Installation & New Features
Msh Sayket
Msh Sayket

Posted on

Laravel 12 Installation & New Features

In this post, I will show you Laravel 12 Installation & New Features and enhancement and let’s review it together. still laravel 12 documents adding more features but right you can review it from github repo.

Laravel 12 Installation & New Features Overview

Installing Laravel 12
Laravel 12 is officially scheduled for release on February 24, 2025. To install the early version, use the following command:

composer create-project --prefer-dist laravel/laravel Laravel12
Enter fullscreen mode Exit fullscreen mode

you will see the new brand home page of laravel 12:

New Features in Laravel 12
Let’s see the one by one features:

  1. Introduction of nestedWhere() for Complex Queries Laravel 12 introduces the nestedWhere() method, simplifying complex query structures. You Can Learn Wire Click Event in Laravel Livewire 3

Before:

$products = Product::select("*")
            ->where("status", 1)
            ->where(function($query) {
                $query->where("price", "orWhere("discount", ">", 25);
            })
            ->get();
Enter fullscreen mode Exit fullscreen mode

After:

$products = Product::select("*")
            ->where("status", 1)
            ->nestedWhere("price", "", 25)
            ->get();
Enter fullscreen mode Exit fullscreen mode

2. Upgrade to Carbon 3

Laravel 12 replaces Carbon 2 with Carbon 3, introducing improved date and time handling.

3. Str::is() Now Matches Multiline Strings

The Str::is() helper (and str()->is()) now correctly matches multiline strings using the regex s modifier. Previously, wildcard patterns (*) did not match newline characters.

Str::is('*', $multilineString); // false
Str::is('first*', $multilineString); // false
Str::is("first\n*", $multilineString); // false
Str::is("first\nsecond\n*", $multilineString); // true
Enter fullscreen mode Exit fullscreen mode

4. Enhanced Security with secureValidate()

Laravel 12 introduces secureValidate() for stronger password validation.

Before:

$request->validate(['password' => 'required|min:8']);
Enter fullscreen mode Exit fullscreen mode

After:

$request->secureValidate(['password' => 'required|min:8|strong']);
Enter fullscreen mode Exit fullscreen mode

5. apiVersion() for API Development

Laravel 12 natively supports GraphQL and introduces apiVersion() for improved API versioning.

Before:

Route::get("v1/users", [UserController::class, "index"]);
Enter fullscreen mode Exit fullscreen mode

After:

Route::apiVersion(1)->group(function() {
    Route::get("users", [UserController::class, "index"]);
});
Enter fullscreen mode Exit fullscreen mode

6. Enhanced Debugging Tools

Laravel 12 introduces AI-powered debugging assistance, featuring a new debug() method to diagnose issues and suggest solutions in real time.

debug($variable)->suggest();
Enter fullscreen mode Exit fullscreen mode

7. Concurrency Result Index Mapping

When using Concurrency::run() with an associative array, the results now maintain their associated keys:

$result = Concurrency::run([
    'task-1' => fn () => 1 + 1,
    'task-2' => fn () => 2 + 2,
]);

// ['task-1' => 2, 'task-2' => 4]
Enter fullscreen mode Exit fullscreen mode

8. Image Validation Now Excludes SVGs by Default

The image validation rule no longer allows SVG images by default. To include SVGs, explicitly allow them:

'photo' => 'required|image:allow_svg'
Enter fullscreen mode Exit fullscreen mode

You Can Learn More from DevScriptSchool

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →