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

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

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

  [ home ](https://www.msaied.com)    [ articles ](https://www.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%2Fwww.msaied.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%2Fwww.msaied.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://www.msaied.com/articles) 

 [ ![DDD Value Objects and DTOs in Laravel Without the Bloat](https://cdn.msaied.com/450/41688537085b86f102fd8c219a35319f.png) laravel ddd php 

### DDD Value Objects and DTOs in Laravel Without the Bloat

Learn how to implement domain-driven value objects and data transfer objects in Laravel using PHP 8.3 readonly...

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

 21 Jul 2026     1 min read  

  Read    

 ](https://www.msaied.com/articles/ddd-value-objects-and-dtos-in-laravel-without-the-bloat) [ ![Laravel + Python FastAPI: Image OCR Demo](https://cdn.msaied.com/447/5f3d87146fbf19957973cbc88c6c0155.png) Laravel Python FastAPI 

### Laravel + Python FastAPI: Image OCR Demo

Learn how to call a Python image OCR script from Laravel using FastAPI as the bridge. This premium tutorial wa...

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

 20 Jul 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-python-fastapi-image-ocr-demo) [ ![Scaffold Laravel Packages with the `laravel package` Command in Installer v5.31.0](https://cdn.msaied.com/449/522e744d3c7bae1f214c179a83ae5b88.png) Laravel Installer Package Development CLI 

### Scaffold Laravel Packages with the `laravel package` Command in Installer v5.31.0

Laravel Installer v5.31.0 introduces a `laravel package` command to scaffold packages from the CLI, automated...

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

 20 Jul 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/scaffold-laravel-packages-with-the-laravel-package-command-in-installer-v5310) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.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://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.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)
