Download the PHP package withfatpanda/bugsnag-mini-php without Composer
On this page you can find all versions of the php package withfatpanda/bugsnag-mini-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download withfatpanda/bugsnag-mini-php
More information about withfatpanda/bugsnag-mini-php
Files in withfatpanda/bugsnag-mini-php
Package bugsnag-mini-php
Short Description A minimal PHP-based implementation of a client for reporting application errors to Bugsnag
License MIT
Informations about the package bugsnag-mini-php
bugsnag-mini-php
This is the most minimal PHP client for Bugsnag that I could conceive of and create.
I wanted to be able to add Bugsnag to an aging PHP codebase I'm working on, but for various reasons, I couldn't easily incorporate the standard PHP library. Fortunately, Bugsnag has an easy to approach JSON API, so I put this client together, and now you can use it too!
Getting Started
If you're adding this to a project that doesn't use Composer, just download
this repository, and copy the file src/busnag-mini.php
into your project.
If you're using Composer, you can incorporate this snip of PHP like a library as follows:
The next thing you'll need to do is create a constant somewhere to store your Bugsnag API key:
The last and most important step is to hook up this client's exception and error handling functions, like so:
Now anytime an Exception
is thrown or an error is raised or the runtime
shutsdown, errors will be sent to Bugsnag.
Customizing Meta Data
You can feed more meta data into Bugsnag by setting up functions that assess the context of the error and provide more context. You can, for example, attach information about affected user, about the app, about the device running the app, and other meta data.
Each of the functions receives as their only argument the Exception
that was
thrown and is being reported upon.
These functions do not exist until you define them in your own codebase. The client will look for them, and will call them only if they exist—this is completely and totally optional.
The functions are as follows:
bugsnag_mini_user
Information about the user affected by the crash.
bugsnag_mini_app
Information about the app that crashed.
bugsnag_mini_device
Information about the computer/device running the app
bugsnag_mini_meta
An object containing any further data you wish to attach to this error event. This should contain one or more objects, with each object being displayed in its own tab on the event details on the Bugsnag website.
Sending errors manually
If ever you want to push an Exception arbitrarily, all you have to
do is call bugsnag_mini_notify($ex)
. For example:
Running the unit test
To ease development and testing, I put together a simple PHPUnit-based test.
To run it, you'll want to edit phpunit.xml
, uncomment and modify the following
section to suit:
This won't actually halt the runtime.
About Fat Panda
Fat Panda is a software product consultancy located in Winchester, VA. We specialize in Laravel, WordPress, and Ionic. No matter where you are in the development of your product, we'll meet you there and work with you to propel you forward.
Contributing
If you run into a problem using this framework, please open an issue.
If you want to help make this framework amazing, check out the help wanted list.
If you'd like to support this and the other open source projects Fat Panda is building, please join our community of supporters on Patreon.