Download the PHP package beter/exception-with-context without Composer
On this page you can find all versions of the php package beter/exception-with-context. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beter/exception-with-context
More information about beter/exception-with-context
Files in beter/exception-with-context
Package exception-with-context
Short Description Interface, Trait and Class of the exception with a context
License MIT
Homepage https://github.com/BETER-CO/php-exception-with-context
Informations about the package exception-with-context
exception-with-context
Requirements
PHP >= 7.4.0
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json.
Usage
Usage of the ExceptionWithContext:
You may create a chain of exceptions too:
You may redefine your base exceptions and add context trait to them. They will behave the same way.
Also, you may implement your own custom exceptions, you even don't need to use traits.
Just implement Beter\Exception\ExceptionWithContextInterface.
Ideas for usage
- add context to log messages;
- protect from flooding exception message with placeholded values right into the message;
- pass more data to sentry/logentries/datadog/newrelic and so on.
You need to implement that support by yourself. There are only ideas.
Development and testing
Follow the development and testing doc.
Related projects
These projects use beter/exception-with-context:
- Bulletproof logging for yii2 projects - BETER-CO/yii2-beter-logging
- Yii2 component to generate log entries with a context for the request and response events for the CLI and WEB - BETER-CO/yii2-log-request-response