Laravel 12: New Features, Helpers, and Practical Upgrade Notes
#laravel #laravel-12 #upgrade #php

Laravel 12: New Features, Helpers, and Practical Upgrade Notes

4 min read Mohamed Said Mohamed Said

What Actually Changed in Laravel 12

Laravel 12 is a minimal-surface release — the framework team deliberately kept breaking changes small so teams can upgrade without a multi-sprint refactor. That does not mean nothing changed. Several decisions affect how you scaffold new projects and which helpers you reach for day-to-day.


Slimmer Application Skeleton

The default laravel/laravel skeleton lost several files that previously shipped but were rarely touched:

  • app/Http/Kernel.php is gone — middleware is now registered entirely in bootstrap/app.php (this started in L11 but L12 finalises the pattern).
  • app/Providers/BroadcastServiceProvider.php and app/Providers/EventServiceProvider.php are no longer generated; their responsibilities live in AppServiceProvider or bootstrap/app.php.
  • The routes/channels.php and routes/console.php files are opt-in rather than always present.

If you are upgrading an existing L11 app, none of your existing files are deleted — the skeleton change only affects laravel new projects.


First-Party Starter Kits

Laravel 12 ships three official starter kits via laravel/breeze and a new laravel/react / laravel/vue path:

# React starter (Inertia v2, TypeScript, Tailwind v4)
laravel new my-app --using=react

# Vue starter
laravel new my-app --using=vue

# Livewire starter (Volt or class-based)
laravel new my-app --using=livewire

Each kit now includes WorkOS AuthKit as an optional authentication layer, giving you social login and SSO out of the box. You can opt out and keep the classic email/password flow.

Practical note: The --using flag delegates to the kit's own installer. If your CI pipeline runs laravel new, pin the kit version explicitly to avoid unexpected scaffold changes between patch releases.


New and Refined Helpers

Number::spell() and Number::ordinal()

use Illuminate\Support\Number;

Number::spell(42);       // "forty-two"
Number::ordinal(3);      // "3rd"
Number::ordinal(21);     // "21st"

These are thin wrappers around PHP's NumberFormatter — no extra dependency, locale-aware via the locale argument.

Str::chopStart() / Str::chopEnd()

Str::chopStart('https://example.com', 'https://'); // "example.com"
Str::chopEnd('report.csv', '.csv');                // "report"

Clean replacements for the ltrim/rtrim + manual prefix pattern you have written a hundred times.

once() helper

function expensiveComputation(): int
{
    return once(fn () => /* runs exactly once per request lifecycle */ 42);
}

once() memoises the return value of a closure for the duration of the request (or Octane worker tick). It is backed by Illuminate\Support\Once and is safe across repeated calls from different call sites.


Upgrade Checklist

For teams moving from Laravel 11:

  1. Run php artisan about on L11 first; note any custom providers.
  2. Update composer.json: "laravel/framework": "^12.0".
  3. Check your bootstrap/app.php — if you registered middleware in a custom Kernel, migrate it to the fluent API:
// bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->append(\App\Http\Middleware\TrustProxies::class);
    })
    ->create();
  1. Search for Illuminate\Http\Middleware\TrustHosts — it is now enabled by default; remove duplicate registrations.
  2. Run php artisan config:clear && php artisan cache:clear before deploying.
  3. Review the official upgrade guide for any package-specific notes (Sanctum, Passport, Telescope all have L12-compatible releases).

Should You Upgrade Now?

If you are on L11 and your app is stable, upgrading is low-risk. The breaking changes are narrow and well-documented. New projects should start on L12 immediately to benefit from the cleaner skeleton and updated starter kits.


Key Takeaways

  • The skeleton is leaner — Kernel.php is gone, providers are consolidated.
  • Three official starter kits (react, vue, livewire) with optional WorkOS auth.
  • Str::chopStart(), Str::chopEnd(), Number::spell(), Number::ordinal(), and once() are worth adopting immediately.
  • Upgrading from L11 is straightforward; the main work is migrating any custom Kernel middleware to bootstrap/app.php.
  • Pin starter kit versions in CI to avoid scaffold drift.

Found this useful?

Frequently Asked Questions

3 questions
Q01 Is upgrading from Laravel 11 to Laravel 12 a large effort?
No. Laravel 12 has a small breaking-change surface. Most teams complete the upgrade in a few hours. The main task is migrating any custom HTTP Kernel middleware registrations to the fluent API in bootstrap/app.php.
Q02 What is the `once()` helper and when should I use it?
once() memoises a closure's return value for the lifetime of the current request or Octane worker tick. Use it to avoid redundant expensive computations — database lookups, heavy calculations — that are called from multiple places but should only run once per request.
Q03 Do the new starter kits replace Laravel Breeze and Jetstream?
The new --using flag kits are the spiritual successor to Breeze for React/Vue/Livewire stacks. Jetstream remains a separate package for teams that need its team management features. Breeze itself is updated to delegate to the new kits.

Continue reading

More Articles

View all