While at ZendCon2017 this year, I ran across bugsnag in the vendor exhibit hall, and decided I needed to add them to one of my production sites, so I could be notified whenever issues arose.


While bugsnag works with virtually every PHP framework, my site runs off a homegrown framework, so I had to install bugsnag as a standalone. Installing bugsnag is pretty straightforward:

  1. Add to composer
    composer require bugsnag/bugsnag:^3.0
  2. Update Composer
    composer update
  3. Add to the codebase
    $bugsnag = Bugsnag\Client::make("your_api_key");
  4. Run your code

That’s all you need to register bugsnag as the error handler on your site. On my system, that meant that I put the code in my front controller, and unhandled exceptions on all pages were tracked and sent to bugsnag.

Minor Issue

The “unhandled exceptions” in the previous paragraph is important. Bugsnag will register itself as the error handler for all unhandled errors. In order to deal with other errors, you need to notify bugsnag with the error object caught in the exception:

    // Some potentially crashy code
} catch (Exception $ex) {

However, my homegrown system doesn’t have a quick and easy way to create a global object and pass that information along to each of the controllers (at least not without a moderate rewrite). For the moment, I need to track exceptions locally, though because my site doesn’t take any user input, and generally disrupts attempts at modifying the URL, this integration will work for me until I rewrite the homegrown system.

Other Frameworks

Thankfully, if you use another framework, bugsnag provides integrations for them.

Why I Like Bugsnag

The main reason I installed bugsnag is that it will give me the full stack trace, the user IP address, lists of cookies and other extra data for each error that arises.

While I can get all that information with local development debug tools, bugsnag allows me to get notified by phone or email when errors arise in production, and I can log in with my smartphone and check all of these details from anywhere, and decide then if it’s a serious enough issue to drop everything and get to work on the bug.


Also, since my site is a free, donation enabled site, the bugsnag pricing model of $0 works for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.