The filter no-ops in CLI runs (CodeIgniter sets is_cli() === true for spark
commands and queue workers). When ENVIRONMENT === 'testing' it does run,
because the test suite needs to exercise the bypass path.
If you want a queue worker to honour maintenance, call the helper explicitly:
if (maintenance()->isActive()) {
return; // skip this run
}Yes — apply the filter only to the routes you want to guard. Use the alias in
route definitions instead of $globals:
$routes->group('admin', ['filter' => 'maintenance'], function ($routes) {
// ...
});/health, webhook callbacks, and similar should usually be left out of the
filter.
Not yet. It's on the roadmap. For now, work around it by:
- Running multiple CodeIgniter apps with separate caches, OR
- Using
$cacheKeyper tenant — set it dynamically inapp/Config/Maintenance.php's constructor.
The bundled 503 view is HTML. JSON content negotiation (Accept: application/json) is also on the roadmap. In the meantime, override
$customTemplate with a view that emits JSON, or wrap the filter and inspect
the request yourself.
No. The cache driver uses CI4's cache abstraction, which works with file,
APCu, Memcached, Redis, etc. The file driver writes directly to
WRITEPATH/maintenance/.
Yes — that's exactly what php spark mm:migrate does. See
storage-drivers.md.
Either:
- Set
Config\Maintenance::$customTemplate = 'errors/html/my_503', or php spark mm:publishand editapp/Views/errors/html/error_503.php.
Variables passed to the template: $message, $data (the MaintenanceData
DTO), $config (the Config\Maintenance instance).
No. The 503 still costs CPU/RAM to render. Park your DDoS protection at the CDN / load-balancer layer.
An HTTP header that tells well-behaved clients (CDNs, search engine crawlers,
browsers' fetch retries) how long to wait before retrying. Configure it via
Config\Maintenance::$retryAfterSeconds. Sprint 3 will allow an HTTP-date
value too, useful when you have a known maintenance end time.
Different cause from the test issue. In production, query parameters arrive
with the request. Check that $config->allowSecretBypass = true AND that the
client actually hits the URL with ?maintenance_secret=…. Run
php spark mm:status from the same shell as your web server — its CLI
"Access Status" panel walks the bypass logic step by step.