Code review at scale is broken. Hereโ€™s how Augment Code is fixing it.

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
Laravel Code Review

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

Visit Laravel Code Review
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
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
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
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
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
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 →
Query Builder Expression Aliases in Laravel 12.48 image

Query Builder Expression Aliases in Laravel 12.48

Read article
Restrict User Actions with Time-Based Sanctions Using Laravel Prohibitions image

Restrict User Actions with Time-Based Sanctions Using Laravel Prohibitions

Read article
Laravel Invite Only Adds a Full User Invitation System with Tokens, Events, and Reminders image

Laravel Invite Only Adds a Full User Invitation System with Tokens, Events, and Reminders

Read article
Docker Support in Laravel VS Code Extension v1.4.2 image

Docker Support in Laravel VS Code Extension v1.4.2

Read article
Laravel Deadlock: Manage Technical Debt with Expiring Code Markers image

Laravel Deadlock: Manage Technical Debt with Expiring Code Markers

Read article
Filament v5 Released With Livewire v4 Support and a New Blueprint Tool image

Filament v5 Released With Livewire v4 Support and a New Blueprint Tool

Read article