PHPackages                             morrislaptop/error-tracker-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. morrislaptop/error-tracker-adapter

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

morrislaptop/error-tracker-adapter
==================================

Track errors and exceptions through the most popular Saas platforms

v0.2.0(11y ago)718.1k11MITPHP

Since Feb 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/morrislaptop/error-tracker-adapter)[ Packagist](https://packagist.org/packages/morrislaptop/error-tracker-adapter)[ RSS](/packages/morrislaptop-error-tracker-adapter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (1)

error-tracker-adapter
=====================

[](#error-tracker-adapter)

[![Build Status](https://camo.githubusercontent.com/808b69f8eddb20108906697d0357e7b7f8c7a7ed24219981c38fd44c47862c5b/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6d6f727269736c6170746f702f6572726f722d747261636b65722d616461707465722e706e67)](http://travis-ci.org/morrislaptop/error-tracker-adapter)[![Total Downloads](https://camo.githubusercontent.com/13c949d4701dfaec9b92e02b3bb1f7668f7865743b0e948bd5a275c9d6b6a3cb/68747470733a2f2f706f7365722e707567782e6f72672f6d6f727269736c6170746f702f6572726f722d747261636b65722d616461707465722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/morrislaptop/error-tracker-adapter)[![Latest Stable Version](https://camo.githubusercontent.com/312f9169f937d2a909df3adb1a591286d4eab38ae69c8b6c6623df7f293c6677/68747470733a2f2f706f7365722e707567782e6f72672f6d6f727269736c6170746f702f6572726f722d747261636b65722d616461707465722f762f737461626c652e706e67)](https://packagist.org/packages/morrislaptop/error-tracker-adapter)

Track errors and exceptions through the most popular SaaS platforms.

**Error Tracker Adapter** is a PHP library which helps you track exceptions and errors in your application by providing a powerful abstraction layer for error tracker SaaS platforms and / or local repositories like emails and log files.

It has been created on three main principles:

- [Code to an interface and not an implementation](https://www.google.co.uk/?q=code%20to%20an%20interface)
- [Protecting yourself from third party APIs breaking your application](http://butunclebob.com/ArticleS.JamesGrenning.AlternativeToTheHopeAndPrayMethod)
- The ability to use chain or net like reporting for redundancy and/or increased reliability of errors being reported

Architecture
------------

[](#architecture)

### SaaS Platforms

[](#saas-platforms)

SaaS platforms are supported via the use of adapters, the currently supported platforms are:

- [Sentry](https://getsentry.com/) via [raven/raven](https://github.com/getsentry/raven-php)
- [Bugsnag](https://bugsnag.com/) via [bugsnag/bugsnag](https://github.com/bugsnag/bugsnag-php)
- [AirBrake](https://airbrake.io/) via [dbltr/php-airbrake](https://github.com/dbtlr/php-airbrake)
- [Rollbar](https://rollbar.com/) via [rollbar/rollbar](https://github.com/rollbar/rollbar-php)
- [Exceptiontrap](https://exceptiontrap.com/) via [exceptiontrap/exceptiontrap](https://github.com/itmLABS/exceptiontrap-php)
- [Raygun](https://raygun.io/) via [mindscape/raygun4php](https://github.com/MindscapeHQ/raygun4php)
- [Bugify](https://bugify.com/)

### Local Repositories

[](#local-repositories)

Local repositories like emails, logs or database are supported via the use of providers, the currently supported repositories are:

- Email Repoter via [error-tracker-adapter-email](https://github.com/morrislaptop/error-tracker-adapter-email)
- Log Reporter

If you use [Monolog](https://github.com/Seldaek/monolog), you now have the ability to log your exceptions into any of it's handlers - Pushover notifications, HipChat, Flowdock, Slack etc..

```
$monolog = new Monolog\Logger();
$monolog->pushHandler(new FlowdockHandler('apiToken', Monolog\Logger::ERROR));
$logger = new Morrislaptop\ErrorTracker\Provider\Log($monolog);
```

### Grouping Trackers

[](#grouping-trackers)

Also, you can use Group trackers which can use multiple trackers in different ways:

- Chain Reporter for reporting until one is successful (e.g. falling back to a log if Sentry is down)
- Net Reporter for reporting to all trackers (e.g. logging AND reporting to Sentry for redundancy)

### Extending Things

[](#extending-things)

You can write your own provider or adapter by implementing the `Tracker` interface. Optionally you can use the other interfaces `Adapter`, `Provider` or `Group` and/or extend the abstract classes `AbstractAdapter`, `AbstractProvider` or `AbstractGroup` to help classify your trackers.

Installation
------------

[](#installation)

The recommended way to install is through [Composer](http://getcomposer.org):

```
$ composer require morrislaptop/error-tracker-adapter

```

### Quick Start

[](#quick-start)

For convenience, a generic exception handler is included with the library so you can quickly get started, by simply creating it and calling the `bootstrap()` method.

```
$tracker = new Morrislaptop\ErrorTracker\Adapter\Sentry(new Raven_Client('https://blah.com'));
// or
$tracker = new Morrislaptop\ErrorTracker\Adapter\BugSnag(new Bugsnag_Client('2344324342'));

$handler = new Morrislaptop\ErrorTracker\ExceptionHandler($tracker);
$handler->bootstrap();
```

Usage
-----

[](#usage)

The use of this library is a *reporter* and not a renderer. So it's recommended that you handle exceptions in your application with your own class and then report to the interface if it's the right error type and/or environment.

An example exception handler for your application might look like..

```
