Opencart errors to Bugsnag

The Bugsnag error reporter for your Opencart gives you instant notification of errors and exceptions in your Opencart site
Wouldn't be nice to have our opencart errors reported to the wonderful Bugsnag dashboard?

This is already possible. Follow steps below.

  • First, download guzzle.phar and bugsnag.phar. See this link for the download links: https://docs.bugsnag.com/platforms/php/other/#installation

  • Copy these guzzle.phar and bugsnag.phar to your Opencart. I copied them to: system/octv/libs.

  • In index.php and admin/index.php locate the error handler set_error_handler('error_handler'); and add:

require DIR_SYSTEM . "octv/libs/guzzle.phar";
require DIR_SYSTEM . "octv/libs/bugsnag.phar";
$bugsnag = Bugsnag\Client::make("YOUR_BUGSNAG_KEY");
$registry->set('Bs', $bugsnag); //Let Bs become available in $this
//Bugsnag\Handler::register($bugsnag);
Bugsnag\Handler::registerWithPrevious($bugsnag); 

Conclusion

Now as soon as an unexpected error happens in your live ecommerce site, you are notified by email, great, isn’t it?