PHPackages                             salines/cakephp-airbrake - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. salines/cakephp-airbrake

ActiveCakephp-plugin[Debugging &amp; Profiling](/categories/debugging)

salines/cakephp-airbrake
========================

CakePHP 5.x plugin for Airbrake error tracking and exception monitoring

v1.0.1(2mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Jan 16Pushed 2mo agoCompare

[ Source](https://github.com/salines/cakephp-airbrake)[ Packagist](https://packagist.org/packages/salines/cakephp-airbrake)[ Docs](https://github.com/salines/cakephp-airbrake)[ RSS](/packages/salines-cakephp-airbrake/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

CakePHP Airbrake Plugin
=======================

[](#cakephp-airbrake-plugin)

[![CI](https://github.com/salines/cakephp-airbrake/actions/workflows/ci.yml/badge.svg)](https://github.com/salines/cakephp-airbrake/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![CakePHP 5.x](https://camo.githubusercontent.com/a234092bcb3e553ee870fb29ec6351957a12a2266170f1d1fee3cda2cf545950/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43616b655048502d352e782d7265642e737667)](https://cakephp.org)[![PHP 8.1+](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://php.net)

A native CakePHP 5.x plugin for [Airbrake](https://airbrake.io/) error tracking and exception monitoring. Automatically captures and reports exceptions, PHP errors, and log messages to Airbrake using API v3. This plugin does not depend on the legacy phpairbrake SDK.

**No external dependencies** - uses CakePHP's built-in HTTP client.

Features
--------

[](#features)

- Native implementation using Airbrake API v3
- No phpairbrake SDK dependency
- Automatic exception and error tracking
- Seamless integration with CakePHP's error handling system
- Log engine for sending log messages to Airbrake
- Request context (URL, HTTP method, route, user agent, etc.)
- CakePHP route information (controller, action, prefix)
- User identification support (CakePHP Authentication plugin)
- Sensitive data filtering (passwords, tokens, etc.)
- Support for self-hosted Airbrake (Errbit)
- Environment-based configuration
- Zero external dependencies

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- CakePHP 5.x
- Airbrake account (or self-hosted Errbit)

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

[](#installation)

Install the plugin using Composer:

```
composer require salines/cakephp-airbrake
```

Migration from phpairbrake
--------------------------

[](#migration-from-phpairbrake)

If your application previously used the phpairbrake SDK, you can remove it from `composer.json` and keep the same Airbrake credentials. This plugin provides its own notifier (`CakeAirbrake\Notifier`) and sends notices directly using CakePHP's HTTP client.

Configuration
-------------

[](#configuration)

### 1. Load the Plugin

[](#1-load-the-plugin)

Add the plugin to your `src/Application.php`:

```
use CakeAirbrake\CakeAirbrakePlugin;

public function bootstrap(): void
{
    parent::bootstrap();

    $this->addPlugin(CakeAirbrakePlugin::class);
}
```

### 2. Configure Airbrake

[](#2-configure-airbrake)

Add the Airbrake configuration to your `config/app.php`:

```
'Airbrake' => [
    'projectId' => env('AIRBRAKE_PROJECT_ID'),
    'projectKey' => env('AIRBRAKE_PROJECT_KEY'),
    'environment' => env('APP_ENV', 'production'),
    'appVersion' => '1.0.0',
    'host' => 'https://api.airbrake.io', // Change for self-hosted
    'enabled' => true,
    'rootDirectory' => ROOT,
    'keysBlocklist' => [
        '/password/i',
        '/secret/i',
        '/token/i',
        '/authorization/i',
        '/api_key/i',
    ],
],
```

### 3. Configure Error Logger

[](#3-configure-error-logger)

To automatically send all exceptions and errors to Airbrake, configure the error logger in `config/app.php`:

```
'Error' => [
    'errorLevel' => E_ALL,
    'exceptionRenderer' => \Cake\Error\Renderer\WebExceptionRenderer::class,
    'skipLog' => [],
    'log' => true,
    'trace' => true,
    'logger' => \CakeAirbrake\Error\AirbrakeErrorLogger::class,
],
```

### 4. Configure Log Engine (Optional)

[](#4-configure-log-engine-optional)

To send log messages to Airbrake, add the log engine configuration:

```
'Log' => [
    'airbrake' => [
        'className' => 'CakeAirbrake.Airbrake',
        'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
    ],
],
```

The log engine automatically uses the global `Airbrake` configuration.

Environment Variables
---------------------

[](#environment-variables)

You can configure the plugin using environment variables:

```
AIRBRAKE_PROJECT_ID=123456
AIRBRAKE_PROJECT_KEY=your-project-key
AIRBRAKE_HOST=https://api.airbrake.io
AIRBRAKE_ENABLED=true
APP_ENV=production
```

Usage
-----

[](#usage)

### Automatic Error Tracking

[](#automatic-error-tracking)

Once configured with the error logger, all uncaught exceptions and PHP errors will automatically be sent to Airbrake.

### Manual Exception Reporting

[](#manual-exception-reporting)

You can manually send exceptions to Airbrake:

```
use CakeAirbrake\Notifier;
use Cake\Core\Configure;

try {
    // Your code
} catch (\Exception $e) {
    $notifier = new Notifier(Configure::read('Airbrake'));
    $notifier->notify($e);
}
```

### Using the Log Engine

[](#using-the-log-engine)

Send log messages to Airbrake:

```
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,
]);
```

### Adding Custom Context

[](#adding-custom-context)

You can add custom context to your error reports using filters:

```
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);
```

### Filtering Notices

[](#filtering-notices)

You can prevent certain notices from being sent by returning `null` from a filter:

```
$notifier->addFilter(function ($notice) {
    // Don't send 404 errors
    if (str_contains($notice['errors'][0]['type'], 'NotFoundException')) {
        return null;
    }
    return $notice;
});
```

### Setting Severity

[](#setting-severity)

You can set the severity level for notices:

```
$notifier = new Notifier(Configure::read('Airbrake'));
$notice = $notifier->buildNotice($exception);
$notice['context']['severity'] = 'critical'; // debug, info, notice, warning, error, critical
$notifier->sendNotice($notice);
```

### Testing With webhook.site

[](#testing-with-webhooksite)

You can test delivery without a real Airbrake project by sending notices to a webhook.site URL.

1. Create a new endpoint at  and copy the unique URL.
2. Configure a custom notices URL:

```
'Airbrake' => [
    'projectId' => 1,
    'projectKey' => 'test-key',
    'customNoticesUrl' => 'https://webhook.site/your-unique-id',
],
```

3. Trigger a test notice:

```
use CakeAirbrake\Notifier;
use Cake\Core\Configure;

$notifier = new Notifier(Configure::read('Airbrake'));
$notifier->notify(new \RuntimeException('Webhook test notice'));
```

Open the webhook.site page to inspect the JSON payload.

Configuration Options
---------------------

[](#configuration-options)

OptionTypeDefaultDescription`projectId`intnullYour Airbrake project ID (required)`projectKey`stringnullYour Airbrake project key (required)`environment`string'production'Environment name`appVersion`stringnullApplication version`host`string''Airbrake API host`enabled`booltrueEnable/disable Airbrake reporting`keysBlocklist`array\[...\]Regex patterns for sensitive keys to filter`rootDirectory`stringROOTRoot directory for backtrace filtering`httpClientOptions`array\['timeout' =&gt; 10\]Options for CakePHP HTTP ClientSelf-Hosted Airbrake (Errbit)
-----------------------------

[](#self-hosted-airbrake-errbit)

To use with a self-hosted Airbrake server like [Errbit](https://github.com/errbit/errbit):

```
'Airbrake' => [
    'projectId' => 1,
    'projectKey' => 'your-api-key',
    'host' => 'https://your-errbit-server.com',
    // ... other options
],
```

Filtering Sensitive Data
------------------------

[](#filtering-sensitive-data)

The plugin automatically filters sensitive data based on the `keysBlocklist` configuration. By default, it filters keys matching:

- `/password/i`
- `/secret/i`
- `/token/i`
- `/authorization/i`
- `/api_key/i`
- `/apikey/i`
- `/access_token/i`

You can add your own patterns:

```
'keysBlocklist' => [
    '/password/i',
    '/secret/i',
    '/credit_card/i',
    '/ssn/i',
    '/cvv/i',
],
```

Disabling in Development
------------------------

[](#disabling-in-development)

You can disable Airbrake in development:

```
'Airbrake' => [
    // ... other config
    'enabled' => !Configure::read('debug'),
],
```

Or using environment variables:

```
AIRBRAKE_ENABLED=false
```

Notice Structure
----------------

[](#notice-structure)

The plugin sends notices to Airbrake in the following structure (API v3):

```
{
  "errors": [{
    "type": "RuntimeException",
    "message": "Something went wrong",
    "backtrace": [...]
  }],
  "context": {
    "notifier": {"name": "cakephp-airbrake", "version": "1.0.0"},
    "environment": "production",
    "hostname": "server-01",
    "os": "Linux",
    "language": "PHP 8.1.0",
    "severity": "error",
    "url": "https://example.com/users/123",
    "httpMethod": "GET",
    "route": "/Users/view",
    "component": "Users",
    "action": "view",
    "user": {"id": 1, "name": "John", "email": "john@example.com"}
  },
  "environment": {...},
  "params": {...},
  "session": {...}
}
```

Testing
-------

[](#testing)

Run the tests:

```
composer install
./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Credits
-------

[](#credits)

- [Airbrake](https://airbrake.io/) - Error monitoring service
- [CakePHP](https://cakephp.org/) - PHP framework

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance85

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Total

2

Last Release

77d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c76b15b14e0fcff89ce5823c02769ee5d3ae3b3e7523d74c619d744390af5967?d=identicon)[salines](/maintainers/salines)

---

Tags

airbrakecakephpcakephp-plugincakephp5error-handlingerror-trackingphpcakephperror-monitoringexception handlingairbrakeerror-trackingerrbit

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/salines-cakephp-airbrake/health.svg)

```
[![Health](https://phpackages.com/badges/salines-cakephp-airbrake/health.svg)](https://phpackages.com/packages/salines-cakephp-airbrake)
```

###  Alternatives

[laracraft-tech/laravel-xhprof

Easy XHProf setup to profile your laravel application!

235321.4k](/packages/laracraft-tech-laravel-xhprof)[lordsimal/cakephp-sentry

Sentry plugin for CakePHP

12270.3k](/packages/lordsimal-cakephp-sentry)[emgiezet/errbit-php

errbit/airbrake integration with php with psr-2

44146.2k3](/packages/emgiezet-errbit-php)[dereuromark/cakephp-whoops

Whoops error handler for CakePHP

1492.4k1](/packages/dereuromark-cakephp-whoops)[bavix/laravel-xhprof

Quick profiling of your code for Laravel

22156.6k](/packages/bavix-laravel-xhprof)[h4cc/phpqatools

A meta composer package for PHP QA Tools.

6418.6k1](/packages/h4cc-phpqatools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
