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

ActiveYii2-extension[Logging &amp; Monitoring](/categories/logging)

nohnaimer/yii2-sentry
=====================

Yii2 logger for Sentry

2.0.0(2y ago)045.7k↓18.4%3MITPHPPHP ^7.2|^8.0

Since Dec 29Pushed 4mo agoCompare

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

READMEChangelogDependencies (6)Versions (26)Used By (0)

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/9d8349aa0f2a6e449c55ccd8b5f4f66f3dc31b7b952d279a9985e0dc9b8769bf/68747470733a2f2f706f7365722e707567782e6f72672f6e6f686e61696d65722f796969322d73656e7472792f762f737461626c65)](https://packagist.org/packages/nohnaimer/yii2-sentry)[![Total Downloads](https://camo.githubusercontent.com/6e37191a335d4c856ea7e68c4a8b7a5b40c301db76f37e11a33745d127b00aa6/68747470733a2f2f706f7365722e707567782e6f72672f6e6f686e61696d65722f796969322d73656e7472792f646f776e6c6f616473)](https://packagist.org/packages/nohnaimer/yii2-sentry)[![License](https://camo.githubusercontent.com/9628a2d3b16123cd1aac19f479c2004e4ae388600f1c5b0db500456006ff513f/68747470733a2f2f706f7365722e707567782e6f72672f6e6f686e61696d65722f796969322d73656e7472792f6c6963656e7365)](https://packagist.org/packages/nohnaimer/yii2-sentry)

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

[](#installation)

```
composer require nohnaimer/yii2-sentry
```

Add target class in the application config:

```
return [
    'components' => [
        'sentry' => [
            'class' => 'nohnaimer\sentry\Component',
            'dsn' => 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',
            // Additional options for `Sentry\init`:
            'clientOptions' => [
                'release' => 'my-project-name@2.3.12',
                //Performance Monitoring
                'traces_sample_rate' => 1.0,
            ],
            //collect JavaScript errors, default false
            'jsNotifier' => true,
            //Collect javascript errors to different project
            'jsDsn' => 'http://6cfe124dfafd4fa98ac0a7f7cfccf187@sentry.io/2',
            // Additional options for javascript `Sentry\init`:
            'jsClientOptions' => [
                'release' => 'my-project-name@2.3.12',
                //Performance Monitoring
                'integrations' => '[new Sentry.Integrations.BrowserTracing()]',
                'tracesSampleRate' => 0.2,
            ],
            // Write the context information (the default is true):
            'context' => true,
            //add Environment application
            'environment' => 'test',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'nohnaimer\sentry\Target',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
    ],
];
```

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' => 'nohnaimer\sentry\Target',
            'levels' => ['error', 'warning'],
            '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');
```

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

48

—

FairBetter than 95% of packages

Maintenance50

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 52.3% 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 ~128 days

Recently: every ~269 days

Total

24

Last Release

829d ago

Major Versions

1.8.5 → 2.0.02024-02-09

PHP version history (3 changes)1.4.0PHP ^7.1

1.6.0-betaPHP ^7.2

1.8.2PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c0b6415ee49d051979bc8aa20ef52e654a9598b9091db92646dbc802a82700c?d=identicon)[nohnaimer](/maintainers/nohnaimer)

---

Top Contributors

[![niksamokhvalov](https://avatars.githubusercontent.com/u/8028275?v=4)](https://github.com/niksamokhvalov "niksamokhvalov (45 commits)")[![nohnaimer](https://avatars.githubusercontent.com/u/8865830?v=4)](https://github.com/nohnaimer "nohnaimer (17 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)")[![dmhaiduchonak](https://avatars.githubusercontent.com/u/29248?v=4)](https://github.com/dmhaiduchonak "dmhaiduchonak (2 commits)")[![i-sevostyanov](https://avatars.githubusercontent.com/u/1166655?v=4)](https://github.com/i-sevostyanov "i-sevostyanov (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)")[![dawidrylko](https://avatars.githubusercontent.com/u/11761319?v=4)](https://github.com/dawidrylko "dawidrylko (1 commits)")[![Julian-B90](https://avatars.githubusercontent.com/u/4377396?v=4)](https://github.com/Julian-B90 "Julian-B90 (1 commits)")[![Shmakov](https://avatars.githubusercontent.com/u/606514?v=4)](https://github.com/Shmakov "Shmakov (1 commits)")[![mitrm](https://avatars.githubusercontent.com/u/9912491?v=4)](https://github.com/mitrm "mitrm (1 commits)")

---

Tags

sentryyii2

###  Code Quality

TestsCodeception

### Embed Badge

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

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