Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 1.68 KB

File metadata and controls

74 lines (52 loc) · 1.68 KB

Installation

Requirements

  • PHP 8.2 or newer
  • CodeIgniter 4.x
  • codeigniter4/settings ^2.2 (installed automatically)

Install

composer require daycry/maintenancemode

Composer's files autoload registers the global maintenance() helper, so you can call it from anywhere immediately after install.

Publish the config

The package ships sensible defaults, but most users want to publish a local copy of Config\Maintenance so they can pin secrets and choose a driver:

php spark mm:publish

This creates app/Config/Maintenance.php (and the package's 503 view skeleton under app/Views/errors/). Edit those files freely — you own them.

Verify

php spark mm:status

You should see something like:

✅ **** Application is LIVE ****
Users can access the application normally.

Storage method: Cache

If you see "MAINTENANCE MODE" instead, run php spark mm:up first to clear any leftover state.

Wire the filter

To make the package actually intercept HTTP requests, add the filter alias and apply it to whatever routes you want guarded. In app/Config/Filters.php:

public array $aliases = [
    // ...
    'maintenance' => \Daycry\Maintenance\Filters\Maintenance::class,
];

public array $globals = [
    'before' => [
        'maintenance', // applies to every request
    ],
    'after' => [],
];

If you'd rather guard a subset of routes, use route-level filters in app/Config/Routes.php instead of $globals.

Next steps