<?php require_once 'php-airbrake-notifier/Services/Airbrake.php'; require_once 'pheanstalk/pheanstalk_init.php'; $airbrake = new Services_Airbrake(HOPTOAD_API_KEY); $k = array_rand($BEANSTALK_SERVERS); $pheanstalk = new Pheanstalk($BEANSTALK_SERVERS[$k]['host'], $BEANSTALK_SERVERS[$k]['port']); $pheanstalk->watch('airbrake')->ignore('default'); while ($job = $pheanstalk->reserve()) { $data = json_decode($job->getData()); echo date('Y-m-d H:i:s') . ' Processing Error: ' . $data->url . "\n"; $airbrake->curlRequest($data->url, $data->headers, $data->body); $pheanstalk->delete($job); }
// register Services_Airbrake for php errors and raised exceptions // when used in your staging environment require_once 'Services/Airbrake.php'; Services_Airbrake::installHandlers("YOUR_AIRBRAKE_API_KEY", 'staging'); ?> <?php // register Services_Airbrake for php errors and raised exceptions // when used in production and using the Curl transport require_once 'Services/Airbrake.php'; Services_Airbrake::installHandlers("YOUR_AIRBRAKE_API_KEY", 'production', 'curl'); ?> <?php // standalone require_once 'Services/Airbrake.php'; Services_Airbrake::$apiKey = "YOUR_AIRBRAKE_API_KEY"; $exception = new Custom_Exception('foobar'); Services_Airbrake::handleException($exception); ?> <?php // use Zend_Http_Client require_once 'Services/Airbrake.php'; Services_Airbrake::$apiKey = "YOUR_AIRBRAKE_API_KEY"; Services_Airbrake::$client = "zend"; $exception = new Custom_Exception('foobar'); Services_Airbrake::handleException($exception); ?>
<?php $payload = getPayload(); require_once dirname(__FILE__) . '/lib/Airbrake.class.php'; $brake = new Services_Airbrake($payload->api_key, 'production', 'curl'); // YOUR WORKER CODE HERE try { //do something } catch (Exception $e) { $brake->notify(get_class($e), $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTrace(), "worker"); }