Maintenance
Learn how to use maintenance mode to make it easier to make adjustments, update scripts, and change settings without interference.
Command line
In the terminal, you can activate maintenance mode with the following command:
./run app:down
If it's a Windows server, or the run file is marked as executable, you don't need the ./ prefix; use the command like this:
run app:down
After executing the command, all requests will issue HTTP error code 503.
To deactivate maintenance mode, restoring its functionalities, execute the command:
./run app:up
If it's a Windows server, or the run file is marked as executable, you don't need the ./ prefix, use the command like this:
run app:up
Activate dynamically
It is possible to activate maintenance mode by calling the Inphinit\App::down() method.
You can create a route for active maintenance mode, but it is important to use some security condition, example:
use Inphinit\App;
$app->action('GET', '/down', function () {
if (condition) {
App::down();
return 'Down website for the next requests';
} else {
Response::status(403);
}
});
Deactivate dynamically
It is possible to deactivate maintenance mode by calling the Inphinit\App::up() method.
You can create a route for deactive maintenance mode, but it is important to use some security condition, example:
use Inphinit\App;
$app->action('GET', '/down', function () {
if (condition) {
App::down();
return 'Up website for the next requests';
} else {
Response::status(403);
}
});
Bypass maintenance
To ignore maintenance mode even when it is enabled, you can configure the 'maintenance' event. For example, if a specific IP needs to test the application, you can configure something like:
use Inphinit\Event;
Event::on('maintenance', function () {
if ($_SERVER['REMOTE_ADDR'] === '...') {
// Stop propagation and disable maintenance at runtime
return false;
}
});