PHP code example of dbtlr / php-airbrake

1. Go to this page and download the library: Download dbtlr/php-airbrake library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dbtlr / php-airbrake example snippets



ake\EventHandler::start('[your api key]');


Key  = '[your api key]'; // This is $config = new Airbrake\Configuration($apiKey, $options);
$client = new Airbrake\Client($config);

// Send just an error message
$client->notifyOnError('My error message');

// Send an exception that may have been generated or caught.
try {
    throw new Exception('This is my exception');

} catch (Exception $exception) {
    $client->notifyOnException($exception);
}



$config = Airbrake\EventHandler::getClient()->getConfiguration();
$config->addFilter('user');



$config = Airbrake\EventHandler::getClient()->getConfiguration();
$config->addFilter('user[password]');



class MyFilter implements Airbrake\Filter\FilterInterface
{
  public function filter(&$post_data)
  {
    if (array_key_exists('some_key', $post_data)){
      unset($post_data['some_key']);
    }
  }
}
$config = Airbrake\EventHandler::getClient()->getConfiguration();
$config->addFilter(new MyFilter());



class MyErrorFilter implements Airbrake\EventFilter\Error\FilterInterface
{
  public function shouldSendError($type, $message, $file, $line, $context = null)
  {
    if ($type == E_STRICT && preg_match('/LegacyController.php/', $file)){
      return false;
    }
  }
}

$airbrake = Airbrake\EventHandler::start();
$airbrake->addErrorFilter(new MyErrorFilter());




class MyExceptionFilter implements Airbrake\EventFilter\Exception\FilterInterface
{
  public function shouldSendException($exception)
  {
    return !($exception instanceof AclException);
  }
}

$airbrake = Airbrake\EventHandler::start();
$airbrake->addExceptionFilter(new MyExceptionFilter());
 javascript
{
  "airbrake": "~1.1"
  }
}
 bash
curl -s http://getcomposer.org/installer | php
php composer.phar install