PHPackages                             silinternational/yii2-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. silinternational/yii2-sentry

Abandoned → [sil-org/yii2-sentry](/?search=sil-org%2Fyii2-sentry)Yii2-extension[Logging &amp; Monitoring](/categories/logging)

silinternational/yii2-sentry
============================

Yii2 logger for Sentry

2.1.2(7mo ago)06861MITPHPPHP ^8.1CI passing

Since Dec 11Pushed 6mo agoCompare

[ Source](https://github.com/sil-org/yii2-sentry)[ Packagist](https://packagist.org/packages/silinternational/yii2-sentry)[ RSS](/packages/silinternational-yii2-sentry/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (7)Used By (0)

[Sentry](https://sentry.io) logger for Yii2
===========================================

[](#sentry-logger-for-yii2)

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

[](#installation)

```
composer require sil-org/yii2-sentry
```

Add target class in the application config:

```
return [
    'components' => [
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'Sil\Sentry\SentryTarget',
                    'dsn' => 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',
                    'levels' => ['error', 'warning'],
                    // Write the context information (the default is true):
                    'context' => true,
                    // Additional options for `Sentry\init`:
                    'clientOptions' => ['release' => 'my-project-name@2.3.12']
                ],
            ],
        ],
    ],
];
```

Usage
-----

[](#usage)

Writing simple message:

```
\Yii::error('message', 'category');
```

Writing messages with extra data:

```
\Yii::warning([
    'msg' => 'message',
    'extra' => 'value',
], 'category');
```

### Extra callback

[](#extra-callback)

`extraCallback` property can modify extra's data as callable function:

```
    'targets' => [
        [
            'class' => 'Sil\Sentry\SentryTarget',
            'dsn' => 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',
            'levels' => ['error', 'warning'],
            'context' => true, // Write the context information. The default is true.
            'extraCallback' => function ($message, $extra) {
                // some manipulation with data
                $extra['some_data'] = \Yii::$app->someComponent->someMethod();
                return $extra;
            }
        ],
    ],
```

### Tags

[](#tags)

Writing messages with additional tags. If need to add additional tags for event, add `tags` key in message. Tags are various key/value pairs that get assigned to an event, and can later be used as a breakdown or quick access to finding related events.

Example:

```
\Yii::warning([
    'msg' => 'message',
    'extra' => 'value',
    'tags' => [
        'extraTagKey' => 'extraTagValue',
    ]
], 'category');
```

If all messages need the same tag, use tagCallback in SentryTarget config:

```
    'targets' => [
        [
            'class' => 'Sil\Sentry\SentryTarget',
            'dsn' => 'https://11111111111111111111111111111111@11111111111111111.ingest.us.sentry.io/1111111111111111',
            'levels' => ['error', 'warning'],
            'tagCallback' => function ($tags) {
                $tags['foo'] = 'bar';
                return $tags;
            },
        ],
    ],
```

More about tags see

### Additional context

[](#additional-context)

You can add additional context (such as user information, fingerprint, etc) by calling `\Sentry\configureScope()` before logging. For example in main configuration on `beforeAction` event (real place will dependant on your project):

```
return [
    // ...
    'on beforeAction' => function (\yii\base\ActionEvent $event) {
        /** @var \yii\web\User $user */
        $user = Yii::$app->has('user', true) ? Yii::$app->get('user', false) : null;
        if ($user && ($identity = $user->getIdentity(false))) {
            \Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($identity) {
                $scope->setUser([
                    // User ID and IP will be added by logger automatically
                    'username' => $identity->username,
                    'email' => $identity->email,
                ]);
            });
        }

        return $event->isValid;
    },
    // ...
];
```

Log levels
----------

[](#log-levels)

Yii2 log levels converts to Sentry levels:

```
\yii\log\Logger::LEVEL_ERROR => 'error',
\yii\log\Logger::LEVEL_WARNING => 'warning',
\yii\log\Logger::LEVEL_INFO => 'info',
\yii\log\Logger::LEVEL_TRACE => 'debug',
\yii\log\Logger::LEVEL_PROFILE_BEGIN => 'debug',
\yii\log\Logger::LEVEL_PROFILE_END => 'debug',

```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance65

Regular maintenance activity

Popularity14

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

4

Last Release

239d ago

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

2.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/836739aa4f60c754dc9a4a547ebd0c166e4b6e855d9f119df2be5aec92f3a375?d=identicon)[forevermatt](/maintainers/forevermatt)

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

![](https://www.gravatar.com/avatar/5256eacae3564eb6d3e954abc6552ed99a6d948d94d2b07cc1dc9dabb0bce108?d=identicon)[jason-jackson](/maintainers/jason-jackson)

![](https://www.gravatar.com/avatar/1948ad6f3cf2b7f0b3ca357e8014830ceb955d79f8e13777288c6bd3ed1b8545?d=identicon)[Schparky](/maintainers/Schparky)

---

Top Contributors

[![niksamokhvalov](https://avatars.githubusercontent.com/u/8028275?v=4)](https://github.com/niksamokhvalov "niksamokhvalov (45 commits)")[![briskt](https://avatars.githubusercontent.com/u/3172830?v=4)](https://github.com/briskt "briskt (11 commits)")[![jason-jackson](https://avatars.githubusercontent.com/u/35783387?v=4)](https://github.com/jason-jackson "jason-jackson (10 commits)")[![senor-artemisio](https://avatars.githubusercontent.com/u/1178789?v=4)](https://github.com/senor-artemisio "senor-artemisio (6 commits)")[![CookiesEater](https://avatars.githubusercontent.com/u/1815942?v=4)](https://github.com/CookiesEater "CookiesEater (5 commits)")[![nixmen](https://avatars.githubusercontent.com/u/7568437?v=4)](https://github.com/nixmen "nixmen (4 commits)")[![SilverFire](https://avatars.githubusercontent.com/u/4499203?v=4)](https://github.com/SilverFire "SilverFire (3 commits)")[![dmhaiduchonak](https://avatars.githubusercontent.com/u/29248?v=4)](https://github.com/dmhaiduchonak "dmhaiduchonak (2 commits)")[![mitrm](https://avatars.githubusercontent.com/u/9912491?v=4)](https://github.com/mitrm "mitrm (1 commits)")[![i-sevostyanov](https://avatars.githubusercontent.com/u/1166655?v=4)](https://github.com/i-sevostyanov "i-sevostyanov (1 commits)")[![forevermatt](https://avatars.githubusercontent.com/u/6233204?v=4)](https://github.com/forevermatt "forevermatt (1 commits)")[![orionchikby](https://avatars.githubusercontent.com/u/19212468?v=4)](https://github.com/orionchikby "orionchikby (1 commits)")[![Perfectio](https://avatars.githubusercontent.com/u/241746583?v=4)](https://github.com/Perfectio "Perfectio (1 commits)")[![Shmakov](https://avatars.githubusercontent.com/u/606514?v=4)](https://github.com/Shmakov "Shmakov (1 commits)")[![Julian-B90](https://avatars.githubusercontent.com/u/4377396?v=4)](https://github.com/Julian-B90 "Julian-B90 (1 commits)")[![dawidrylko](https://avatars.githubusercontent.com/u/11761319?v=4)](https://github.com/dawidrylko "dawidrylko (1 commits)")

---

Tags

sentryyii2

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/silinternational-yii2-sentry/health.svg)

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

###  Alternatives

[notamedia/yii2-sentry

Yii2 logger for Sentry

1272.0M2](/packages/notamedia-yii2-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)
