Giter Site home page Giter Site logo

errbitphp's Introduction

Errbit & Airbrake Client for PHP

Coverage Status Build Status Dependency Status Latest Stable Version

This is a full-featured client to add integration with Errbit (or Airbrake) to any PHP >= 5.3 application.

Original idea and source has no support for php namespaces. Moreover it has a bug and with newest errbit version the xml has not supported chars.

Installation

We haven't put this in PEAR or anything like that (please feel to contribute) so you need to install it locally.

Clone Way

git clone git://github.com/emgiezet/errbitPHP.git

Composer Way

require: {
    ...
    "emgiezet/errbit-php": "dev-master"
  }

Usage

To setup an Errbit instance you need to configure it with an array of parameters. Only two of them are mandatory.

use Errbit\Errbit;

Errbit::instance()
  ->configure(array(
    'api_key'           => 'YOUR API KEY',
    'host'              => 'YOUR ERRBIT HOST, OR api.airbrake.io FOR AIRBRAKE'
  ))
  ->start();

View the full configuration.

This will register error handlers:

set_error_handler();
set_exception_handler();
register_shutdown_function();

And log all the errors intercepted by handlers to your errbit.

If you want to notify an exception manually, you can call notify() without calling a start(). That way you can avoid registering the handlers.

use Errbit\Errbit;

try {
  somethingErrorProne();
} catch (Exception $e) {
  Errbit::instance()->notify(
    $e,
    array('controller'=>'UsersController', 'action'=>'show')
  );
}

Using your own error handler

If you don't want Errbit to install its own error handlers and prefer to use your own, you can just leave out the call to start(), then wherever you catch an Exception (note the errors must be converted to Exceptions), simply call

use Errbit\Errbit;
Errbit::instance()->notify($exception);

With this type of use. Library will not handle the errors collected by:

set_error_handler();
register_shutdown_function();

Using only some of the default handlers

There are three error handlers installed by Errbit: exception, error and fatal.

By default all three are used. If you want to use your own for some handlers, but not for others, pass the list into the start() method.

use Errbit\Errbit;
Errbit::instance()->start(array('error', 'fatal')); // using our own exception handler

Symfony2 Integration

See the documentation for symfony2 integration.

Kohana 3.3 Integration

check out the kohana-errbit for kohana 3.3 integration.

Symfony 1.4 Integration

No namespaces in php 5.2 so this library can't be used. Go to filipc/sfErrbitPlugin and monitor your legacy 1.4 applications.

License & Copyright

Copyright © mmx3.pl 2013 Licensed under the MIT license. Based on idea of git://github.com/flippa/errbit-php.git but rewritten in 90%. See the LICENSE file for details.

Contributors

main idea @flippa OOP Rework, Tests and packaging @emgiezet

Rest of the contributors: Contributors page

Bitdeli Badge

errbitphp's People

Contributors

bitdeli-chef avatar d11wtq avatar danielbeardsley avatar emgiezet avatar maintux avatar stloyd avatar tijsverkoyen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.