Download the PHP package andrewdyer/shutdown-handler without Composer
On this page you can find all versions of the php package andrewdyer/shutdown-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrewdyer/shutdown-handler
More information about andrewdyer/shutdown-handler
Files in andrewdyer/shutdown-handler
Package shutdown-handler
Short Description A shutdown handler for Slim Framework applications that converts fatal errors into consistent HTTP responses
License MIT
Homepage https://github.com/andrewdyer/shutdown-handler
Informations about the package shutdown-handler
Shutdown Handler
A shutdown handler for Slim Framework applications that converts fatal errors into consistent HTTP responses.
Introduction
This library provides a shutdown handler for Slim Framework applications, intercepting fatal errors that would otherwise result in unhandled crashes and transforming them into consistent HTTP responses. The handler is fully composable, allowing different responder and emitter strategies to be combined as required, and integrates seamlessly with existing Slim error handling and response emission workflows to maintain predictable application behaviour.
Prerequisites
- PHP: Version 8.3 or higher is required.
- Composer: Dependency management tool for PHP.
- Slim Framework: Version 4 is required.
Installation
Getting Started
An error responder and response emitter are required before registering the shutdown handler.
1. Create an error responder
Error responders define how errors are transformed into HTTP responses.
Alternatively, wrap existing logic using CallableErrorResponder:
The callable must accept a request, exception, and display flag, and return a PSR-7 response.
2. Create a response emitter
Response emitters are responsible for sending responses to the client.
Alternatively, wrap an existing emitter using CallableResponseEmitter:
The adapter wraps an existing emitter implementation.
Usage
Register the shutdown handler to convert fatal errors into consistent HTTP responses:
The $errorResponder and $responseEmitter values can come from custom implementations or the callable adapters shown in Getting Started.
License
Licensed under the MIT license and is free for private or commercial projects.