1. Go to this page and download the library: Download salines/cakephp-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/ */
salines / cakephp-airbrake example snippets
use CakeAirbrake\CakeAirbrakePlugin;
public function bootstrap(): void
{
parent::bootstrap();
$this->addPlugin(CakeAirbrakePlugin::class);
}
use CakeAirbrake\Notifier;
use Cake\Core\Configure;
try {
// Your code
} catch (\Exception $e) {
$notifier = new Notifier(Configure::read('Airbrake'));
$notifier->notify($e);
}
use Cake\Log\Log;
Log::error('Something went wrong', ['scope' => 'airbrake']);
Log::critical('Database connection failed');
// With exception context
Log::error('Operation failed', [
'exception' => $e,
'user_id' => 123,
]);
use CakeAirbrake\Notifier;
use Cake\Core\Configure;
$notifier = new Notifier(Configure::read('Airbrake'));
$notifier->addFilter(function ($notice) {
$notice['context']['customField'] = 'customValue';
$notice['params']['orderId'] = 12345;
return $notice;
});
$notifier->notify($exception);
use CakeAirbrake\Notifier;
use Cake\Core\Configure;
$notifier = new Notifier(Configure::read('Airbrake'));
$notifier->notify(new \RuntimeException('Webhook test notice'));