1. Go to this page and download the library: Download andrewdyer/shutdown-handler 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/ */
andrewdyer / shutdown-handler example snippets
use AndrewDyer\ShutdownHandler\Contracts\ErrorResponderInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Throwable;
final class MyErrorResponder implements ErrorResponderInterface
{
public function createResponse(
ServerRequestInterface $request,
Throwable $exception,
bool $displayErrorDetails
): ResponseInterface {
// Custom response logic
}
}
use AndrewDyer\ShutdownHandler\Adapters\CallableErrorResponder;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Throwable;
$errorResponder = new CallableErrorResponder(
static fn (
ServerRequestInterface $request,
Throwable $exception,
bool $displayErrorDetails
): ResponseInterface => $httpErrorHandler(
$request,
$exception,
$displayErrorDetails,
false,
false
)
);
use AndrewDyer\ShutdownHandler\Contracts\ResponseEmitterInterface;
use Psr\Http\Message\ResponseInterface;
final class MyResponseEmitter implements ResponseEmitterInterface
{
public function emit(ResponseInterface $response): void
{
// Custom emit logic
}
}
use AndrewDyer\ShutdownHandler\Adapters\CallableResponseEmitter;
use Psr\Http\Message\ResponseInterface;
$responseEmitter = new CallableResponseEmitter(
static fn (ResponseInterface $response): void => $slimEmitter->emit($response)
);
use AndrewDyer\ShutdownHandler\ShutdownHandler;
$shutdownHandler = new ShutdownHandler(
$request,
$errorResponder,
$responseEmitter,
$displayErrorDetails
);
register_shutdown_function($shutdownHandler);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.