Download the PHP package o0khoiclub0o/honeybadger-php without Composer
On this page you can find all versions of the php package o0khoiclub0o/honeybadger-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download o0khoiclub0o/honeybadger-php
More information about o0khoiclub0o/honeybadger-php
Files in o0khoiclub0o/honeybadger-php
Package honeybadger-php
Short Description Unofficial PHP library for reporting errors to honeybadger.io
License MIT
Homepage https://github.com/gevans/honeybadger-php
Informations about the package honeybadger-php
honeybadger-php
honeybadger-php is an unofficial library for reporting application errors to Honeybadger.
Compatibility
honeybadger-php is developed and tested against PHP versions 5.3 and 5.4.
Standalone Installation
Add honeybadger-php to your composer.json
:
Then configure Honeybadger
in your bootstrap/index.php
/initializers:
Your application will then report unhandled errors and exceptions to Honeybadger. That's it!
Slim Installation
Add honeybadger-php to your composer.json
:
Call Honeybadger\Slim::init()
after your application definition:
Additional Integrations
This library will work well by following the standalone installation steps outlined above. However, if you want to integrate your favorite framework, you can use the Slim integration as a reference. If you've written your own integration that you'd like to share, send a pull request adding it to the list:
- Nothing here yet...
Usage
For the most part, Honeybadger works for itself.
It intercepts unhandled errors and uncaught exceptions and sends notifications.
If you want to log arbitrary things which you've caught yourself, you can do something like this:
The ::notify()
call will send the notice over to Honeybadger for
later analysis.
Ignored Environments
Please note that in development mode, Honeybadger will not be notified of exceptions that occur. In production, make sure you sure you set the environment name for Honeybadger. For apps using the Slim integration, Honeybadger will handle this for you by using your app's configured mode:
You can modify which environments are ignored by setting the
development_environments
option in your Honeybadger initializer:
If you choose to override the development_environments
option for whatever
reason, please make sure your test environments are ignored.
Sending Custom Data
Honeybadger allows you to send custom data using Honeybadger::context()
.
Here's an example of sending some user-specific information in a Slim callback:
Now whenever an error occurs, Honeybadger will display the affected user's ID and email address, if available.
Subsequent calls to ::context()
will merge the existing array with any new
data, so you can effectively build up context throughout your request's life
cycle.
Going Beyond Exceptions
You can also pass an array to the Honeybadger::notify()
method and store
whatever you want, not just an exception, anywhere in your app.
Honeybadger::notify()
will get all the information about the error itself. As
for an array, these are the keys you should pass:
error_class
- Use this to group similar errors together. When Honeybadger catches an exception it sends the class name of that exception object.error_message
- This is the title of the error you see in the errors list. For exceptions it is "[ ] : " parameters
- While there are several ways to send additional data to Honeybadger, passing an array asparameters
as in the example above is the most common use case. When Honeybadger catches an exception in a controller, the actual HTTP client request parameters are sent using this key.
Honeybadger merges the array you pass with these default options:
You can override any of those parameters.
Sending shell environment variables when "Going beyond exceptions"
One common request we see is to send shell environment variables along with manual exception notification. We recommend sending them along with CGI data or Rack environment (:cgi_data or :rack_env keys, respectively.)
See Honeybadger::Notice::__construct
in
lib/Honeybadger/Notice.php
for more details.
Filtering
You can specify a whitelist of errors that Honeybadger will not report on. Use this feature when you are so apathetic to certain errors that you don't want them even logged.
This filter will only be applied to automatic notifications, not manual
notifications (when ::notify()
is called directly).
To ignore errors, specify their names in your Honeybadger configuration block:
To ignore only certain errors (and override the defaults), use the ignore_only()
method:
Subclasses of ignored classes will also be ignored.
To ignore certain user agents, add in the ignore_user_agent
attribute:
To ignore exceptions based on other conditions, use ignore_by_filter
:
To replace sensitive information sent to the Honeybadger service with
[FILTERED]
use params_filters
:
To disable sending session data:
Proxy Support
The notifier supports using a proxy, if your server is not able to directly reach the Honeybadger servers. To configure the proxy settings, add the following information to your Honeybadger configuration.
Troubleshooting
TODO
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
The majority of this library's style, API, documentation, and structure directly follows the amazing honeybadger-ruby gem.
License
MIT Licensed. See LICENSE.txt for details.