Laravel 12: Typed Config, Slim Skeleton &amp; Upgrade | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Laravel New in 12: First-Class Typed Config, Slim Skeletons, and Upgrade Notes        On this page       1. [  What Actually Changed in Laravel 12 ](#what-actually-changed-in-laravel-12)
2. [  Typed Configuration Objects ](#typed-configuration-objects)
3. [  Testing Becomes Trivial ](#testing-becomes-trivial)
4. [  The Slimmer Skeleton ](#the-slimmer-skeleton)
5. [  Collection and Helper Additions ](#collection-and-helper-additions)
6. [  collect()-&gt;intersectAssoc() ](#codecollect-gtintersectassoccode)
7. [  Str::chopStart() / Str::chopEnd() ](#codestrchopstartcode-codestrchopendcode)
8. [  Upgrade Notes Worth Acting On ](#upgrade-notes-worth-acting-on)
9. [  Key Takeaways ](#key-takeaways)

  ![Laravel New in 12: First-Class Typed Config, Slim Skeletons, and Upgrade Notes](https://cdn.msaied.com/401/bd0219f2cb584b037df76f985db348f8.png)

  #laravel   #laravel-12   #php   #upgrade  

 Laravel New in 12: First-Class Typed Config, Slim Skeletons, and Upgrade Notes 
================================================================================

     9 Jul 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

  9 sections  

1. [  01   What Actually Changed in Laravel 12  ](#what-actually-changed-in-laravel-12)
2. [  02   Typed Configuration Objects  ](#typed-configuration-objects)
3. [  03   Testing Becomes Trivial  ](#testing-becomes-trivial)
4. [  04   The Slimmer Skeleton  ](#the-slimmer-skeleton)
5. [  05   Collection and Helper Additions  ](#collection-and-helper-additions)
6. [  06   collect()-&gt;intersectAssoc()  ](#codecollect-gtintersectassoccode)
7. [  07   Str::chopStart() / Str::chopEnd()  ](#codestrchopstartcode-codestrchopendcode)
8. [  08   Upgrade Notes Worth Acting On  ](#upgrade-notes-worth-acting-on)
9. [  09   Key Takeaways  ](#key-takeaways)

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

Laravel 12 is a focused release rather than a sweeping rewrite. The headline additions are **typed configuration objects**, a significantly slimmer default application skeleton, and a handful of helper and collection improvements. If you are running Laravel 11 on PHP 8.2+, the upgrade path is straightforward — but a few structural decisions deserve deliberate attention.

---

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

The most architecturally interesting addition is first-class support for binding typed config objects into the service container. Instead of scattering `config('services.stripe.key')` calls throughout your codebase, you can now define a plain PHP object and register it once.

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

```

```php
// AppServiceProvider::register()
$this->app->singleton(StripeConfig::class, fn () => new StripeConfig(
    key: config('services.stripe.key'),
    webhookSecret: config('services.stripe.webhook_secret'),
    testMode: (bool) config('services.stripe.test_mode', false),
));

```

Now any class that type-hints `StripeConfig` receives a fully resolved, IDE-friendly object — no more string-keyed lookups, no more silent `null` surprises when a key is missing.

### Testing Becomes Trivial

```php
it('charges the card in test mode', function () {
    $this->app->instance(StripeConfig::class, new StripeConfig(
        key: 'sk_test_fake',
        webhookSecret: 'whsec_fake',
        testMode: true,
    ));

    // act and assert...
});

```

No more `Config::set()` scattered across test files.

---

The Slimmer Skeleton
--------------------

Laravel 12 ships with far fewer stub files in a fresh `laravel new` project. Several files that previously lived in `app/Http/Middleware/` are now consolidated or removed entirely, with their logic folded into the framework itself.

**What is gone from the default skeleton:**

- `TrimStrings`, `ConvertEmptyStringsToNull`, and `PreventRequestsDuringMaintenance` middleware stubs — they still run, but you no longer own copies unless you publish them.
- The `app/Http/Kernel.php` file is absent; middleware registration lives in `bootstrap/app.php` (introduced in Laravel 11, now the only way).

If your upgrade path involves a legacy `Kernel.php`, the migration is mechanical:

```php
// bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->append(\App\Http\Middleware\MyCustomMiddleware::class);
        $middleware->remove(\Illuminate\Http\Middleware\TrimStrings::class);
    })
    ->create();

```

---

Collection and Helper Additions
-------------------------------

### `collect()->intersectAssoc()`

A long-requested method that compares both keys and values:

```php
$a = collect(['color' => 'red', 'size' => 'M']);
$b = collect(['color' => 'red', 'size' => 'L']);

$a->intersectAssoc($b); // ['color' => 'red']

```

### `Str::chopStart()` / `Str::chopEnd()`

Clean alternatives to `ltrim`/`rtrim` for specific substrings:

```php
Str::chopStart('/api/v1/users', '/api'); // '/v1/users'
Str::chopEnd('report.csv.tmp', '.tmp'); // 'report.csv'

```

---

Upgrade Notes Worth Acting On
-----------------------------

1. **PHP minimum is 8.2.** Drop any `7.x`/`8.0`/`8.1` compatibility shims.
2. **`Model::preventLazyLoading()` is on by default in `local`.** Audit your resources and Nova/Filament panels for N+1s before upgrading.
3. **`assertJsonPath` now validates strict types.** Tests that previously passed with loose comparisons may fail — fix the assertions, not the strictness.
4. **Vite 6 is the default.** If you pinned `vite` in `package.json`, bump it and review your `vite.config.js` for deprecated plugin options.

---

Key Takeaways
-------------

- Typed config objects eliminate string-keyed `config()` calls and make test overrides explicit.
- The slimmer skeleton reduces noise; understand which middleware moved into the framework before upgrading.
- `Str::chopStart/chopEnd` and `intersectAssoc` are small but immediately useful.
- `preventLazyLoading` being on by default in local is a gift — let it surface your N+1s now.
- The upgrade from Laravel 11 is low-risk if you already adopted `bootstrap/app.php` middleware registration.

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Flaravel-new-in-12-first-class-typed-config-slim-skeletons-and-upgrade-notes&text=Laravel+New+in+12%3A+First-Class+Typed+Config%2C+Slim+Skeletons%2C+and+Upgrade+Notes) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmsaied.com%2Farticles%2Flaravel-new-in-12-first-class-typed-config-slim-skeletons-and-upgrade-notes) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Is Laravel 12 a long-term support release?        No. Laravel 12 follows the standard release cycle with 18 months of bug fixes and 2 years of security fixes. Only even-numbered releases on the LTS cadence (like Laravel 6 and 9) have received extended support historically, though the project has moved away from formal LTS designations. 

      Q02  Do typed config objects replace the config() helper entirely?        No. The config() helper still works and is appropriate for simple lookups. Typed config objects shine when multiple classes share the same configuration group, when you want IDE autocompletion, or when you need clean test overrides via app()-&gt;instance(). 

      Q03  Will my existing Laravel 11 app break if lazy loading prevention is now on by default?        Only in the local environment, and only if you have genuine N+1 relationships being accessed without eager loading. It will throw a LazyLoadingViolationException. Fix the underlying queries with with() calls rather than disabling the guard. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://msaied.com/articles) 

 [ ![Laravel API Resources: Sparse Fieldsets, Conditional Relationships, and Versioning](https://cdn.msaied.com/400/67fe9d3c6c505a6f67092e2761690696.png) laravel api resources 

### Laravel API Resources: Sparse Fieldsets, Conditional Relationships, and Versioning

Go beyond basic transformers. Learn how to implement sparse fieldsets, conditionally load relationships, and v...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 9 Jul 2026     3 min read  

  Read    

 ](https://msaied.com/articles/laravel-api-resources-sparse-fieldsets-conditional-relationships-and-versioning-1) [ ![Laravel Eloquent Global Scopes: Bootable Traits, Scope Removal, and Testing Pitfalls](https://cdn.msaied.com/399/71a080bda5c9aa713a95cec2c8b42247.png) laravel eloquent testing 

### Laravel Eloquent Global Scopes: Bootable Traits, Scope Removal, and Testing Pitfalls

Global scopes silently shape every query on a model. Learn how to write bootable trait scopes, safely remove t...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 9 Jul 2026     3 min read  

  Read    

 ](https://msaied.com/articles/laravel-eloquent-global-scopes-bootable-traits-scope-removal-and-testing-pitfalls) [ ![API Rate-Limiting in Laravel: Sliding Windows, Per-Route Limiters, and Redis Precision](https://cdn.msaied.com/398/bb46e069aecd78f39c7ac31e2e1b13e2.png) laravel api redis 

### API Rate-Limiting in Laravel: Sliding Windows, Per-Route Limiters, and Redis Precision

Go beyond the default throttle middleware. Learn how to build sliding-window rate limiters, per-user dynamic l...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 9 Jul 2026     3 min read  

  Read    

 ](https://msaied.com/articles/api-rate-limiting-in-laravel-sliding-windows-per-route-limiters-and-redis-precision) 

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

Explore

- [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
