PHPackages                             connehito/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. connehito/cake-sentry

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

connehito/cake-sentry
=====================

Sentry plugin for CakePHP

4.0.0(4y ago)34543.6k↓27.7%26MITPHPPHP ^7.2 || ^8.0

Since Mar 24Pushed 1y ago6 watchersCompare

[ Source](https://github.com/Connehito/cake-sentry)[ Packagist](https://packagist.org/packages/connehito/cake-sentry)[ RSS](/packages/connehito-cake-sentry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (8)Versions (12)Used By (0)

\[Archived\] CakePHP Sentry Plugin
==================================

[](#archived-cakephp-sentry-plugin)

Use this [CakePHP Sentry Plugin](https://github.com/LordSimal/cakephp-sentry) if you want to use sentry with CakePHP 4.4+.

This project has been archived and is no longer actively maintained because several years have passed without active maintenance.

We appreciate the support and contributions from the community over the years. While this repository will remain available in read-only mode, there will be no further updates or maintenance. Thank you for your understanding and support.

---

CakePHP integration for Sentry.

[![Latest Stable Version](https://camo.githubusercontent.com/5362d68a71e98b17f82685dd1935e0503827f9c1a701cb9ef147d278d335dfed/68747470733a2f2f706f7365722e707567782e6f72672f636f6e6e656869746f2f63616b652d73656e7472792f762f737461626c65)](https://packagist.org/packages/connehito/cake-sentry)[![Total Downloads](https://camo.githubusercontent.com/16e54b7326deb7ea08e101e4f68ce4f507b888d62656c879d1ed3c48a5763031/68747470733a2f2f706f7365722e707567782e6f72672f636f6e6e656869746f2f63616b652d73656e7472792f646f776e6c6f616473)](https://packagist.org/packages/connehito/cake-sentry)[![Build Status](https://camo.githubusercontent.com/61470844f1dad01d8845b49d3e300d7c5f5d125fe28c5e31061eaa4ce55c0302/68747470733a2f2f7472617669732d63692e6f72672f436f6e6e656869746f2f63616b652d73656e7472792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Connehito/cake-sentry)[![codecov](https://camo.githubusercontent.com/99291184328c7f6c6ebad2020a75e7dfccfff6546005646dd383e8b947dc5a2d/68747470733a2f2f636f6465636f762e696f2f67682f636f6e6e656869746f2f63616b652d73656e7472792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/connehito/cake-sentry)[![PHP Code Sniffer](https://github.com/Connehito/cake-sentry/workflows/PHP%20Code%20Sniffer/badge.svg)](https://github.com/Connehito/cake-sentry/workflows/PHP%20Code%20Sniffer/badge.svg)[![License](https://camo.githubusercontent.com/a54fb30d8de537cc5c7052f6644be6ace2fa575b3475afb785dc8a7b2749e899/68747470733a2f2f706f7365722e707567782e6f72672f636f6e6e656869746f2f63616b652d73656e7472792f6c6963656e7365)](https://packagist.org/packages/connehito/cake-sentry)

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

[](#requirements)

- PHP 7.2+ / PHP 8.0+
- CakePHP 4.0+
- and [Sentry](https://sentry.io) account

💡 For CakePHP3.x, use [2.x branch](https://github.com/Connehito/cake-sentry/tree/2.x).

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

[](#installation)

### With composer install.

[](#with-composer-install)

```
composer require connehito/cake-sentry:^3.0

```

If you do not have the ` php-http/async-client-implementation` package, you will need to install it together.
In that case, you will get a message like the following

```
Problem 1
- sentry/sentry[3.2.0, ... , 3.3.0] require php-http/async-client-implementation ^1.0 -> could not be found in any version, but the following packages provide it:

```

Then, you can use the following command to provide a package such as `symfony/http-client`.

```
composer require connehito/cake-sentry symfony/http-client

```

You can find the available packages on [Packagist](https://packagist.org/providers/php-http/async-client-implementation).

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(\Connehito\CakeSentry\Plugin::class);
}
```

Or use cake command.

```
bin/cake plugin load Connehito/CakeSentry

```

That's all! 🎉

NOTE:
If the events(error/exception) don't be captured in Sentry, try changing the order in which the plugins are loaded.
It is recommended to load this plugin after running `BaseApplication::bootstrap()` and loading other plugins.

### 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(): array
    {
        return [
            'CakeSentry.Client.afterSetup' => 'setServerContext',
        ];
    }

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

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

And in `config/bootstrap.php`

```
\Cake\Event\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.
In case you want to handle the information in server request, cake-sentry supports to get `Request` instance in implemented event via `$event->getData('request')`.

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(): array
    {
        return [
            'CakeSentry.Client.beforeCapture' => 'setContext',
        ];
    }

    public function setContext(Event $event): void
    {
        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`

```
\Cake\Event\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(): array
    {
        return [
            'CakeSentry.Client.afterCapture' => 'callbackAfterCapture',
        ];
    }

    public function callbackAfterCapture(Event $event): void
    {
        $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](https://github.com/Connehito/cake-sentry/blob/master/LICENSE).

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 93.9% 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 ~116 days

Recently: every ~92 days

Total

11

Last Release

1814d ago

Major Versions

1.0.0 → 2.0.0-RC12019-11-16

2.0.1 → 3.0.0-RC12020-05-17

2.x-dev → 4.0.0-beta12021-04-10

PHP version history (4 changes)1.0.0PHP ^7.0

2.0.0-RC1PHP ^7.1

3.0.0-RC1PHP ^7.2

4.0.0-beta1PHP ^7.2 || ^8.0

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/7308bfca1f335f367cd1f08501356d6bc065f42e115bdd6bbcd140f0df90fd55?d=identicon)[o0h](/maintainers/o0h)

---

Top Contributors

[![o0h](https://avatars.githubusercontent.com/u/907122?v=4)](https://github.com/o0h "o0h (214 commits)")[![letstalk-nl](https://avatars.githubusercontent.com/u/9513230?v=4)](https://github.com/letstalk-nl "letstalk-nl (5 commits)")[![otukutun](https://avatars.githubusercontent.com/u/1199643?v=4)](https://github.com/otukutun "otukutun (4 commits)")[![jtraulle](https://avatars.githubusercontent.com/u/613615?v=4)](https://github.com/jtraulle "jtraulle (2 commits)")[![BGehrels](https://avatars.githubusercontent.com/u/1008320?v=4)](https://github.com/BGehrels "BGehrels (1 commits)")[![fortkle](https://avatars.githubusercontent.com/u/1576804?v=4)](https://github.com/fortkle "fortkle (1 commits)")[![tenkoma](https://avatars.githubusercontent.com/u/16202?v=4)](https://github.com/tenkoma "tenkoma (1 commits)")

---

Tags

cakephp-plugincakephp3cakephp4psr-3

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/connehito-cake-sentry/health.svg)](https://phpackages.com/packages/connehito-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)

73661.4M66](/packages/sentry-sentry-symfony)[sentry/sdk

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

328134.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)[mito/yii2-sentry

Yii 2 extension for Sentry

92377.7k](/packages/mito-yii2-sentry)

PHPackages © 2026

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