- Notifications
You must be signed in to change notification settings - Fork0
Middleware to create responses with error status code (4xx-5xx)
License
middlewares/error-response
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Middleware to format responses with HTTP error codes (4xx-5xx). Useful to create pretty 404 or 500 error pages.
- PHP >= 7.2
- APSR-7 http library
- APSR-15 middleware dispatcher
This package is installable and autoloadable via Composer asmiddlewares/error-response.
composer require middlewares/error-response
useMiddlewares\ErrorResponse;Dispatcher::run([newMiddlewares\ErrorResponse()]);
The constructor accepts an array of responders, that must implement theMiddlewares\ErrorResponder\ResponderInterface
.This package includes two basic responders: for html and json responses, that are enabled by default if no responders are passed.
//The default responders (for html and js)$responder =newMiddlewares\ErrorResponse();//Use your custom responders$responder =newMiddlewares\ErrorResponse([newMyHtmlResponder(),newMyJsonResponder()]);
Please seeCHANGELOG for more information about recent changes andCONTRIBUTING for contributing details.
The MIT License (MIT). Please seeLICENSE for more information.
About
Middleware to create responses with error status code (4xx-5xx)