PHP code example of middlewares / shutdown

1. Go to this page and download the library: Download middlewares/shutdown 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/ */

    

middlewares / shutdown example snippets


$dispatcher = new Dispatcher([
	(new Middlewares\Shutdown())->retryAfter(60 * 5)
]);

$response = $dispatcher->dispatch(new ServerRequest());

$responseFactory = new MyOwnResponseFactory();

$maintenance = new Middlewares\Shutdown($responseFactory);

//Retry after 5 minutes
$maintenance = (new Middlewares\Shutdown())->retryAfter(60 * 5);

//You can use also a DateTimeInterface object
$maintenance = (new Middlewares\Shutdown())->retryAfter(new Datetime('+5 minutes'));

//Load a html file
$maintenance = (new Middlewares\Shutdown())->render(function () {
	return file_get_contents('503.html');
});