Download the PHP package designcise/bitframe-whoops without Composer
On this page you can find all versions of the php package designcise/bitframe-whoops. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download designcise/bitframe-whoops
More information about designcise/bitframe-whoops
Files in designcise/bitframe-whoops
Package bitframe-whoops
Short Description Whoops error handler middleware
License MIT
Informations about the package bitframe-whoops
BitFrame\Whoops
Whoops error handler middleware to handle application or middleware specific errors.
Installation
Please note that this package requires PHP 8.2.0 or newer.
Quickstart
Instantiating
The constructor has the following signature:
- The first argument to the constructor must be an instance of
Psr\Http\Message\ResponseFactoryInterface
; - The second argument to the constructor must be an implementation of
\BitFrame\Whoops\Provider\ProviderInterface
; - The third argument to the constructor is an optional array of options to specify the following:
catchGlobalErrors
: When set totrue
errors will be handled outside of current batch of middleware set.- Other options are simply method names in
Whoops\Handler\*Handler.php
andBitFrame\Whoops\Handler\*Handler.php
. For example, to setWhoops\Handler\JsonResponseHandler::setJsonApi()
you would pass in:['setJsonApi' => false]
, etc.
As a shortcut, you can also use the static method ErrorHandler::fromNegotiator($factory, $options)
. This would use the \BitFrame\Whoops\Provider\HandlerProviderNegotiator
by default.
How to Run the Middleware
To run the middleware, simply pass in a BitFrame\Whoops\ErrorHandler
instance to your middleware runner / dispatcher.
For example, to handle middleware-specific errors with BitFrame\App
(or other PSR-15 dispatchers) it would look something like this:
To handle global errors with BitFrame\App
(or other PSR-15 dispatchers) it would look something like this:
How Does It Work?
The error handler middleware automatically determines the error handler to use based on the Accept
header. The following error handler providers are included:
BitFrame\Whoops\Provider\HtmlHandlerProvider
forWhoops\Handler\PrettyPageHandler
;BitFrame\Whoops\Provider\JsonHandlerProvider
forWhoops\Handler\JsonResponseHandler
;BitFrame\Whoops\Provider\JsonpHandlerProvider
forBitFrame\Whoops\Handler\JsonpResponseHandler
;BitFrame\Whoops\Provider\TextHandlerProvider
forWhoops\Handler\PlainTextHandler
;BitFrame\Whoops\Provider\XmlHandlerProvider
forWhoops\Handler\XmlResponseHandler
;
Tests
To run the tests you can use the following commands:
Command | Type |
---|---|
composer test |
PHPUnit tests |
composer style |
CodeSniffer |
composer md |
MessDetector |
composer check |
PHPStan |
Contributing
- File issues at https://github.com/designcise/bitframe-whoops/issues
- Issue patches to https://github.com/designcise/bitframe-whoops/pulls
Documentation
Complete documentation for v3 will be available soon.
License
Please see License File for licensing information.
All versions of bitframe-whoops with dependencies
filp/whoops Version ^2.15
psr/http-factory Version ^1.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0