PHPackages                             cakephp-biztech/cake-sentry - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. cakephp-biztech/cake-sentry

ActiveCakephp-plugin[Logging &amp; Monitoring](/categories/logging)

cakephp-biztech/cake-sentry
===========================

Sentry plugin for CakePHP3

3.0.0(5y ago)01.4k2MITPHPPHP ^7.2

Since Mar 24Pushed 2y agoCompare

[ Source](https://github.com/cakephp-biztech/cake-sentry)[ Packagist](https://packagist.org/packages/cakephp-biztech/cake-sentry)[ RSS](/packages/cakephp-biztech-cake-sentry/feed)WikiDiscussions 2.x Synced today

READMEChangelog (1)Dependencies (7)Versions (11)Used By (0)

CakePHP Sentry Plugin
=====================

[](#cakephp-sentry-plugin)

CakePHP integration for Sentry.

[![Latest Stable Version](https://camo.githubusercontent.com/d5f1785fb2e4d3c28efe495e1afff0dfb888fa0a5f7e7d582c696c2c5f18467f/68747470733a2f2f706f7365722e707567782e6f72672f63616b657068702d62697a746563682f63616b652d73656e7472792f762f737461626c65)](https://packagist.org/packages/cakephp-biztech/cake-sentry)[![Total Downloads](https://camo.githubusercontent.com/e7db98eae87b59bcaad543b91560da652569a4b433229de8b91901a54e5ccef3/68747470733a2f2f706f7365722e707567782e6f72672f63616b657068702d62697a746563682f63616b652d73656e7472792f646f776e6c6f616473)](https://packagist.org/packages/cakephp-biztech/cake-sentry)[![Build Status](https://camo.githubusercontent.com/018ad80eab795045b642406e637472ffe57e15df6608639d8598c83c00bdd561/68747470733a2f2f7472617669732d63692e6f72672f63616b657068702d62697a746563682f63616b652d73656e7472792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cakephp-biztech/cake-sentry)[![codecov](https://camo.githubusercontent.com/0b00e383e83b2749cffaec05e43646b80098d9cf467f2781c9b8dd9d9fc87e8e/68747470733a2f2f636f6465636f762e696f2f67682f63616b657068702d62697a746563682f63616b652d73656e7472792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/cakephp-biztech/cake-sentry)[![License](https://camo.githubusercontent.com/7bdca93ca592f40e7cb5bd960da56cb00f9939c8dca817e4712e4bf5cb8e9f64/68747470733a2f2f706f7365722e707567782e6f72672f63616b657068702d62697a746563682f63616b652d73656e7472792f6c6963656e7365)](https://packagist.org/packages/cakephp-biztech/cake-sentry)

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

[](#requirements)

- PHP 7.1+
- CakePHP 3.6+
- and [Sentry](https://sentry.io) account

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

[](#installation)

### With composer install.

[](#with-composer-install)

```
composer require cakephp-biztech/cake-sentry

```

Usage
-----

[](#usage)

### Set config files.

[](#set-config-files)

Write your sentry account info.

```
// in `config/app.php`
return [
    'Sentry' => [
        'dsn' => YOUR_SENTRY_DSN_HERE
    ]
];
```

### Loading plugin.

[](#loading-plugin)

In Application.php

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

    $this->addPlugin(\Biztech\CakeSentry\Plugin::class);
}
```

Or use cake command.

```
bin/cake plugin load Biztech/CakeSentry --bootstrap

```

That's all! 🎉

### Advanced Usage

[](#advanced-usage)

#### Ignore noisy exceptions

[](#ignore-noisy-exceptions)

You can filter out exceptions that make a fuss and harder to determine the issues to address(like PageNotFoundException) Set exceptions not to log in `Error.skipLog`.

ex)

```
// in `config/app.php`
'Error' => [
    'skipLog' => [
        NotFoundException::class,
        MissingRouteException::class,
        MissingControllerException::class,
    ],
]
```

ref: CakePHP Cookbook

### Set Options

[](#set-options)

All configure written in `Configure::write('Sentry')` will be passed to `Sentry\init()`. Please check Sentry's official document [about configuration](https://docs.sentry.io/error-reporting/configuration/?platform=php) and [about php-sdk's configuraion](https://docs.sentry.io/platforms/php/#php-specific-options).

In addition to it, CakeSentry provides event hook to set dynamic values to options more easily if you need. Client dispatch `CakeSentry.Client.afterSetup` event before sending error to sentry. Subscribe the event with your logic.

ex)

```
use Cake\Event\Event;
use Cake\Event\EventListenerInterface;

class SentryOptionsContext implements EventListenerInterface
{
    public function implementedEvents()
    {
        return [
            'CakeSentry.Client.afterSetup' => 'setServerContext',
        ];
    }

    public function setServerContext(Event $event)
    {
        /** @var Client $subject */
        $subject = $event->getSubject();
        $options = $subject->getHub()->getClient()->getOptions();

        $options->setEnvironment('test_app');
        $options->setRelease('2.0.0@dev');
    }
}
```

And in `config/bootstrap.php`

```
EventManager::instance()->on(new SentryOptionsContext());
```

### Send more context

[](#send-more-context)

Client dispatch `CakeSentry.Client.beforeCapture` event before sending error to sentry. You can set context with EventListener.With facade `sentryConfigureScope()` etc, or with `$event->getContext()->getHub()` to access and set context.Calling Raven\_Client's API or returning values, error context will be sent. Now, cake-sentry supports to get `Request` instance in implemented event via `$event->getSubject()->getRequest()`. See also [the section about context in offical doc](https://docs.sentry.io/enriching-error-data/context/?platform=php).

ex)

```
use Cake\Event\Event;
use Cake\Event\EventListenerInterface;
use Cake\Http\ServerRequest;
use Cake\Http\ServerRequestFactory;
use Sentry\State\Scope;

use function Sentry\configureScope as sentryConfigureScope;

class SentryErrorContext implements EventListenerInterface
{
    public function implementedEvents()
    {
        return [
            'CakeSentry.Client.beforeCapture' => 'setContext',
        ];
    }

    public function setContext(Event $event)
    {
        if (PHP_SAPI !== 'cli') {
            /** @var ServerRequest $request */
            $request = $event->getData('request') ?? ServerRequestFactory::fromGlobals();
            $request->trustProxy = true;

            sentryConfigureScope(function (Scope $scope) use ($request, $event) {
                $scope->setTag('app_version',  $request->getHeaderLine('App-Version') ?: 1.0);
                $exception = $event->getData('exception');
                if ($exception) {
                    assert($exception instanceof \Exception);
                    $scope->setTag('status', $exception->getCode());
                }
                $scope->setUser(['ip_address' => $request->clientIp()]);
                $scope->setExtras([
                    'foo' => 'bar',
                    'request attributes' => $request->getAttributes(),
                ]);
            });
        }
    }
}
```

And in `config/bootstrap.php`

```
EventManager::instance()->on(new SentryErrorContext());
```

### Collecting User feedback

[](#collecting-user-feedback)

In `CakeSentry.Client.afterCapture` event, you can get last event ID. See also [offcial doc](https://docs.sentry.io/enriching-error-data/user-feedback/?platform=php#collecting-feedback).

ex)

```
class SentryErrorContext implements EventListenerInterface
{
    public function implementedEvents()
    {
        return [
            'CakeSentry.Client.afterCapture' => 'callbackAfterCapture',
        ];
    }

    public function callbackAfterCapture(Event $event)
    {
        $lastEventId = $event->getData('lastEventId');
    }
}
```

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

[](#contributing)

Pull requests and feedback are very welcome :) on GitHub at

License
-------

[](#license)

The plugin is available as open source under the terms of the [MIT License](LICENSE).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 93.1% of commits — single point of failure

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 ~126 days

Recently: every ~87 days

Total

10

Last Release

1832d ago

Major Versions

1.0.0 → 2.0.0-RC12019-11-16

2.0.1 → 3.0.0-RC12020-05-17

PHP version history (3 changes)1.0.0PHP ^7.0

2.0.0-RC1PHP ^7.1

3.0.0-RC1PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/105db221e6c281108c05a6a7f7f7f358e954979ff8981465da163698e24ab353?d=identicon)[cakephp-biztech](/maintainers/cakephp-biztech)

---

Top Contributors

[![o0h](https://avatars.githubusercontent.com/u/907122?v=4)](https://github.com/o0h "o0h (122 commits)")[![ishan-biztech](https://avatars.githubusercontent.com/u/61005017?v=4)](https://github.com/ishan-biztech "ishan-biztech (4 commits)")[![jtraulle](https://avatars.githubusercontent.com/u/613615?v=4)](https://github.com/jtraulle "jtraulle (2 commits)")[![fortkle](https://avatars.githubusercontent.com/u/1576804?v=4)](https://github.com/fortkle "fortkle (1 commits)")[![jay-biztech](https://avatars.githubusercontent.com/u/74171859?v=4)](https://github.com/jay-biztech "jay-biztech (1 commits)")[![tenkoma](https://avatars.githubusercontent.com/u/16202?v=4)](https://github.com/tenkoma "tenkoma (1 commits)")

---

Tags

cakephpcakephp-pluginphpsentrysentry-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cakephp-biztech-cake-sentry/health.svg)

```
[![Health](https://phpackages.com/badges/cakephp-biztech-cake-sentry/health.svg)](https://phpackages.com/packages/cakephp-biztech-cake-sentry)
```

###  Alternatives

[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)[sentry/sentry-symfony

Symfony integration for Sentry (http://getsentry.com)

73761.4M65](/packages/sentry-sentry-symfony)[sentry/sdk

This is a meta package of sentry/sentry. We recommend using sentry/sentry directly.

327134.8M151](/packages/sentry-sdk)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)[stayallive/wp-sentry

A (unofficial) WordPress plugin to report PHP and JavaScript errors to Sentry.

379197.9k](/packages/stayallive-wp-sentry)[bgalati/monolog-sentry-handler

Sentry handler for PHP SDK v2/v3

60837.4k4](/packages/bgalati-monolog-sentry-handler)

PHPackages © 2026

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