Jump24 - Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

Cache Routes and Config During Testing in Laravel 12.38

Last updated on by

Cache Routes and Config During Testing in Laravel 12.38 image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

The Laravel team released version 12.38.0, adding a WithCachedRoutes test trait, a WithCachedConfig test trait, a model prompt for the model:show command, and more.

WithCachedRoutes Testing Trait

Luke Kuzmish contributed the WithCachedRoutes trait, which builds routes once and stores them in memory. Routes are only built once for all tests in your test suite:

use App\Http\Controllers\UserController;
use Illuminate\Foundation\Testing\WithCachedRoutes;
use Tests\TestCase;
 
// Pest
pest()->use(WithCachedRoutes::class);
 
test('basic example', function () {
$this->get(action([UserController::class, 'index']));
 
// ...
});
 
// PHPUnit
class BasicTest extends TestCase
{
use WithCachedRoutes;
 
/**
* A basic functional test example.
*/
public function test_basic_example(): void
{
$response = $this->get(action([UserController::class, 'index']));
 
// ...
}
}

See Pull Request #57623 for more info.

WithCachedConfig Testing Trait

Luke Kuzmish contributed a WithCachedConfig trait, which builds the configuration in your app once and reuses it for all tests:

use Illuminate\Foundation\Testing\WithCachedConfig;
use Tests\TestCase;
 
// Pest
pest()->use(WithCachedConfig::class);
 
test('modifies config', function () {
config(['services.postmark.key' => 'xyz']);
expect(config('services.postmark.key'))->toBe('xyz');
});
 
test('uses default config', function () {
expect(config('services.postmark.key'))->not->toBe('xyz');
});
 
// PHPUnit
class ConfigTest extends TestCase
{
use WithCachedConfig;
 
/**
* A test that modifies the config.
*/
public function test_modifies_config(): void
{
$this->assertEquals('xyz', config('services.postmark.key'));
}
 
/**
* A test that makes no modification to the config.
*/
public function test_uses_default_config(): void
{
$this->assertNotEquals('xyz', config('services.postmark.key'));
}
}

See Pull Request #57663 for more info.

The model:show Command Now Prompts for Input

Razin Shaikh contributed an update to the model:show command to prompt for input when you run the command without arguments. Here's a before-and-after example:

Before Laravel 12.38
Before Laravel 12.38
Starting in Laravel 12.38+
Starting in Laravel 12.38+

See Pull Request #57671 for more info.

Release notes

You can see the complete list of new features and updates below and the diff between 12.37.0 and 12.38.0 on GitHub. The following release notes are directly from the changelog:

v12.38.0

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Driver-Based Architecture in Spatie's Laravel PDF v2 image

Driver-Based Architecture in Spatie's Laravel PDF v2

Read article
Why Your Livewire Dashboard Jumps (And How to Fix It) - Laravel In Practice EP18 image

Why Your Livewire Dashboard Jumps (And How to Fix It) - Laravel In Practice EP18

Read article
Laravel Live UK returns to London on June 18-19, 2026 image

Laravel Live UK returns to London on June 18-19, 2026

Read article
Laravel Related Content: Semantic Relationships Using pgvector image

Laravel Related Content: Semantic Relationships Using pgvector

Read article
Filament v5.2.0 Adds a Callout Component image

Filament v5.2.0 Adds a Callout Component

Read article
OpenAI Releases GPT-5.3-Codex, a New Codex Model for Agent-Style Development image

OpenAI Releases GPT-5.3-Codex, a New Codex Model for Agent-Style Development

Read article