Laravel 12: Typed Config, Fluent Routing &amp; Upgrade | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://msaied.com) - [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [About](https://msaied.com#about)

           [  Contact](https://msaied.com#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://msaied.com)
- [ProjectsCase studies](https://msaied.com/projects)
- [ArticlesEngineering notes](https://msaied.com/articles)
- [CertificatesCredentials](https://msaied.com/certificates)
- [AboutHow I work](https://msaied.com#about)
- [ContactGet in touch](https://msaied.com#contact)

  [Start a conversation](https://msaied.com#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://msaied.com)
2. /
3. [Articles](https://msaied.com/articles)
4. /
5. Laravel New in 12: First-Class Typed Config, Fluent Routing, and Upgrade Notes

 Laravel New in 12: First-Class Typed Config, Fluent Routing, and Upgrade Notes
===============================================================================

 Laravel 12 ships with typed configuration objects, a fluent route definition API, and streamlined bootstrapping. This post covers the practical changes that matter most for production applications.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://msaied.com#person) Published 3 Oct 2026 · Updated 3 Oct 2026 · 4 min read

ShareCopy linkCopied

 ![Laravel New in 12: First-Class Typed Config, Fluent Routing, and Upgrade Notes](https://cdn.msaied.com/735/2b11b2815a5984a8e3ab654b67f9af60.png) 

  On this page +1. [What Actually Changed in Laravel 12](#what-actually-changed-in-laravel-12)
2. [Typed Configuration Objects](#typed-configuration-objects)
3. [Fluent Route Definitions](#fluent-route-definitions)
4. [Bootstrapping Pipeline Changes](#bootstrapping-pipeline-changes)
5. [Upgrade Notes](#upgrade-notes)
6. [Takeaways](#takeaways)

 What Actually Changed in Laravel 12
-----------------------------------

Laravel 12 is a refinement release rather than a paradigm shift, but several additions meaningfully improve day-to-day ergonomics. The three areas worth your attention are **typed configuration objects**, the **fluent route definition API**, and changes to the **application bootstrapping pipeline**.

---

Typed Configuration Objects
---------------------------

The most impactful addition is first-class support for PHP 8.x typed config classes. Instead of scattering `config('services.stripe.secret')` calls across your codebase, you define a plain PHP object and bind it in a service provider.

```php
// app/Config/StripeConfig.php
readonly class StripeConfig
{
    public function __construct(
        public string $secret,
        public string $webhookSecret,
        public bool $testMode = false,
    ) {}
}

```

```php
// AppServiceProvider::register()
$this->app->scoped(StripeConfig::class, fn () => new StripeConfig(
    secret: config('services.stripe.secret'),
    webhookSecret: config('services.stripe.webhook_secret'),
    testMode: app()->environment('local', 'testing'),
));

```

Now inject `StripeConfig` directly into any constructor. Your IDE autocompletes, PHPStan validates, and tests swap the binding trivially:

```php
$this->app->instance(StripeConfig::class, new StripeConfig(
    secret: 'sk_test_fake',
    webhookSecret: 'whsec_fake',
    testMode: true,
));

```

This is not a new Laravel feature in isolation — the container has always supported this — but Laravel 12 documents and encourages it as the canonical pattern, and the starter kits scaffold it by default.

---

Fluent Route Definitions
------------------------

Laravel 12 introduces a fluent `Route` builder that keeps controller, middleware, and naming on a single expression without chaining off the facade:

```php
use App\Http\Controllers\InvoiceController;
use Illuminate\Support\Facades\Route;

Route::get('/invoices/{invoice}', InvoiceController::class)
    ->name('invoices.show')
    ->middleware(['auth', 'verified'])
    ->can('view', 'invoice');

```

The `->can()` shorthand wires a `Gate::authorize()` call before the controller fires, replacing the boilerplate `authorize()` call inside the controller method. For resource controllers the pattern extends cleanly:

```php
Route::resource('invoices', InvoiceController::class)
    ->middleware('auth')
    ->only(['index', 'show', 'store']);

```

The underlying `ResourceRegistrar` now respects a per-resource middleware stack, so you no longer need a route group solely to scope middleware to one resource.

---

Bootstrapping Pipeline Changes
------------------------------

The `bootstrap/app.php` file introduced in Laravel 11 is refined in Laravel 12. Exception rendering and routing are now registered via explicit `withExceptions` and `withRouting` calls, and the order is guaranteed:

```php
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->web(append: [\App\Http\Middleware\SetLocale::class]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        $exceptions->render(fn (\App\Exceptions\PaymentException $e, Request $r) =>
            response()->json(['error' => $e->getMessage()], 402)
        );
    })
    ->create();

```

The key upgrade note: if you maintained a custom `App\Http\Kernel`, the migration path is to move middleware groups into `withMiddleware` closures. The old kernel class is still supported in Laravel 12 but will be removed in a future major version.

---

Upgrade Notes
-------------

- Run `php artisan about` after upgrading — it now surfaces the resolved config driver and cache store, useful for spotting misconfiguration.
- The `Str::password()` helper signature changed; the `symbols` parameter is now a `bool` not a `string`. Update any calls that passed a custom symbol set.
- Minimum PHP version is **8.2**. PHP 8.1 is no longer supported.
- `Http::pool()` now returns a typed `Pool` object; destructuring the result array still works but the individual responses are `Response` instances, not raw arrays.

---

Takeaways
---------

- Adopt typed config objects now — they eliminate magic string lookups and make testing trivial.
- The fluent `->can()` shorthand on routes removes boilerplate `authorize()` calls from controllers.
- Migrate away from `App\Http\Kernel` proactively; the new `withMiddleware` API is cleaner and future-proof.
- PHP 8.2 is the floor — if you are still on 8.1, upgrade before touching Laravel 12.
- `bootstrap/app.php` is now the single source of truth for routing, middleware, and exception handling.

- [laravel](https://msaied.com/articles?search=laravel)
- [laravel-12](https://msaied.com/articles?search=laravel-12)
- [upgrade](https://msaied.com/articles?search=upgrade)
- [routing](https://msaied.com/articles?search=routing)
- [configuration](https://msaied.com/articles?search=configuration)

 Frequently asked questions 
---------------------------

  Is the old App\\Http\\Kernel still supported in Laravel 12?Yes, Laravel 12 still supports the legacy Kernel class for backward compatibility, but it is deprecated. You should migrate middleware registration to the withMiddleware closure in bootstrap/app.php before the next major release removes it.

   Do typed config objects require any new Laravel 12 APIs?No. Typed config objects use the standard service container. Laravel 12 simply promotes this pattern in its documentation and starter kits. You can backport the pattern to Laravel 10 or 11 without any framework changes.

   What is the minimum PHP version for Laravel 12?Laravel 12 requires PHP 8.2 or higher. PHP 8.1 support was dropped, so you must upgrade your runtime before installing Laravel 12.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://msaied.com#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://msaied.com#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLaravel Octane + FrankenPHP: Request Lifecycle, Shared State, and Safe Singleton Patterns](https://msaied.com/articles/laravel-octane-frankenphp-request-lifecycle-shared-state-and-safe-singleton-patterns)  

   On this page
-------------

1. [What Actually Changed in Laravel 12](#what-actually-changed-in-laravel-12)
2. [Typed Configuration Objects](#typed-configuration-objects)
3. [Fluent Route Definitions](#fluent-route-definitions)
4. [Bootstrapping Pipeline Changes](#bootstrapping-pipeline-changes)
5. [Upgrade Notes](#upgrade-notes)
6. [Takeaways](#takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://msaied.com#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/731/7cabd03b86a18f1db2c9ff7de1510270.png)  · 3 min read### Laravel Octane + FrankenPHP: Request Lifecycle, Shared State, and Safe Singleton Patterns

3 Oct 2026 ](https://msaied.com/articles/laravel-octane-frankenphp-request-lifecycle-shared-state-and-safe-singleton-patterns) [ ![](https://cdn.msaied.com/728/b96439f5ef5f084b44d736951875f964.png)  · 3 min read### Eloquent Custom Relations: Polymorphic Pivots, Has-One-Of-Many, and Raw Join Relations

2 Oct 2026 ](https://msaied.com/articles/eloquent-custom-relations-polymorphic-pivots-has-one-of-many-and-raw-join-relations) [ ![](https://cdn.msaied.com/727/7873d7495db459e7a6e3bfbb8835852d.png)  · 3 min read### Laravel Caching Strategies: Tags, Stampede Prevention, and Cache-Aside at Scale

2 Oct 2026 ](https://msaied.com/articles/laravel-caching-strategies-tags-stampede-prevention-and-cache-aside-at-scale-2) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://msaied.com#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://msaied.com)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://msaied.com/sitemap.xml)
