Laravel 12–13 · PHP 8.2–8.5 · MIT
Never serve stale Laravel config or routes after a deployment.
Detect relevant source changes before Laravel boots, reject stale deployment cache and repair safely — even on FTP or shared hosting where exec() is disabled.
composer require codegenie-be/laravel-config-cache-guard
That single Composer command completes installation. Optionally verify it with php artisan config-cache-guard:status. No change to public/index.php is required.
Verified behavior
A real Laravel 13 repair scenario
The flow below mirrors the package E2E test: Composer installs the package into a fresh application, source files change, PHP runs with exec() disabled and real HTTP requests verify the uncached and repaired states.
Before Laravel boots
How it works
- DetectComposer loads the guard before
bootstrap/app.php. It compares safe file metadata signatures. - RejectChanged sources make stale config cache unavailable and route cache move to a current signature-based path.
- RepairUse PHP CLI when available, or queue internal
Artisan::call()repair after the response. - ContinueThe request never needs to consume known-stale config or routes. Later requests use rebuilt cache.
Supported runtimes
Compatibility
| Laravel | PHP | Status |
|---|---|---|
| 12 | 8.2–8.5 | Supported |
| 13 | 8.3–8.5 | Supported |
A date-aware CI policy rejects PHP or Laravel versions after they reach end of life.
Security and privacy
- Does not read or store
.envvalues - Does not send telemetry or external requests
- Uses file locks and safe diagnostic markers
- Exposes no public repair endpoint
- Passes no user input to shell commands
Common questions
FAQ
Does this make every Laravel website faster?
No. The package protects deployment cache correctness. It preserves or rebuilds cache already used by the application, but it does not automatically optimize every website.
Does it automatically enable config or route cache?
No. Missing config cache creation is opt-in through CONFIG_CACHE_GUARD_CREATE_CONFIG_CACHE=true. Route guarding starts when route cache already exists.
What happens when exec() is disabled?
Stale config is removed, stale routes are bypassed, a safe pending marker is written and Laravel rebuilds internally through Artisan::call() after the response.
Should deployment scripts still run config:cache?
Yes. Reliable deployment commands remain the preferred production flow. The package protects applications when those steps are skipped or unavailable.
Add a safety net with one Composer command.
composer require codegenie-be/laravel-config-cache-guard