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

ActiveCakephp-plugin

shopforward/cake-sentry
=======================

Sentry plugin for CakePHP

5.0.0(4y ago)05.6kMITPHPPHP ^7.2 || ^8.0

Since May 30Pushed 3y agoCompare

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

READMEChangelog (3)Dependencies (8)Versions (5)Used By (0)

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

[](#cakephp-sentry-plugin)

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

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 95.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 ~284 days

Total

3

Last Release

1241d ago

Major Versions

1.0.0 → 5.0.02021-05-30

PHP version history (2 changes)1.0.0PHP ^7.2 || ^8.0

1.1.0PHP ^7.2 || ^8.0 || ^8.1 || ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/89648759c303504e066317bbc5a0c2d50c7c115675a8cc344eab6c46e7722265?d=identicon)[paulcelie](/maintainers/paulcelie)

---

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)")[![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)")[![paulcelie](https://avatars.githubusercontent.com/u/4981763?v=4)](https://github.com/paulcelie "paulcelie (1 commits)")[![tenkoma](https://avatars.githubusercontent.com/u/16202?v=4)](https://github.com/tenkoma "tenkoma (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sentry/sentry-laravel

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

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

CakePHP plugin for creating and/or rendering Pdfs, several Pdf engines supported.

3752.1M3](/packages/friendsofcake-cakepdf)[cakephp/bake

Bake plugin for CakePHP

11211.2M158](/packages/cakephp-bake)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

338920.1k32](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308850.3k14](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1862.1M27](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

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