Download the PHP package marcoazn89/booboo without Composer
On this page you can find all versions of the php package marcoazn89/booboo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marcoazn89/booboo
More information about marcoazn89/booboo
Files in marcoazn89/booboo
Package booboo
Short Description A framework to handle your production boo-boo's
License MIT
Homepage https://github.com/marcoazn89/booboo
Informations about the package booboo
Install via Composer
composer require marcoazn89/booboo:dev-master
Features
- Dynamic error templates for production errors
- Content negotiation to show the right error format (HTML, JSON, XML, etc)
- PSR-3 compliant (set your own logger)
- PSR-7 compliant (pass a response object with headers and status code)
Run BooBoo
This is something you want to do at the begining of your application.
The setUp() method takes 4 parameters:
1) $logger: BooBoo will use error_log by default. If you want to use your own you can pass a psr2 logger compliant like Monolog
.
2) $traceAlwaysOn: Turn of or off stack traces. By default they are turned off. You can always turn it on or off later when you throw an exception, but any other regular exception or php error will use the setting defined at the set up
3) $lastAction: This is a callback that will be ran before exiting the application upon encountering an error
4) $ignore: This is an array containing php error constants that you want to ignore.
What happens when an error occurs?
BooBoo pays attention to Accept headers
Client requesting JSON
Client requesting XML
Creating exceptions and templates
1) Simply extend and implement the two abstract methods
2) Templates get the following varibles injected:
- $response: The psr7 response object
- $message: The message that was defined for the template or null if none was provided
- $data: Any data that was passed to the template or null if none was provided
3) Throw the exception
Set limits on what you can support
The order in which you add support matters! This will ignore any Accept
headers that don't match the supported types. Learn more from http-wrapper
How BooBoo connects errors with HTTP responses:
- Any HTTP 500+ status code and fatal error will translate into a critical log level because they are system errors.
- Any HTTP status code in the 400 range will translate into a warning log level because they are client generated errors. This only applies for the exceptions you define by extending BooBoo.
- Any php non fatal error or message will translate into an error log level.