1. Go to this page and download the library: Download jarir-ahmed/kill-switch library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jarir-ahmed / kill-switch example snippets
use JarirAhmed\KillSwitch\KillSwitch\KillSwitchManager;
use JarirAhmed\KillSwitch\KillSwitch\KillSwitchMiddleware;
use JarirAhmed\KillSwitch\KillSwitch\MaintenanceResponder;
use Nyholm\Psr7\Factory\Psr17Factory;
$config = [
'env_var' => 'KILL_SWITCH_ENABLED',
'file_path' => __DIR__ . '/../storage/kill-switch.txt',
'file_enabled_value' => '1',
'db' => [
'connection' => 'mysql:host=localhost;dbname=app',
'table' => 'settings',
'column' => 'enabled',
'id' => 1,
],
'view_path' => null,
'message' => 'We are In Maintenance Mode',
'retry_after' => 3600,
];
$manager = new KillSwitchManager($config);
$responseFactory = new Psr17Factory();
$responder = new MaintenanceResponder($config, $responseFactory);
$middleware = new KillSwitchMiddleware($manager, $responder);
// Add to your PSR-15 middleware stack
$stack->add($middleware);