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

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

dfware/sentry
=============

Yii2 logger for Sentry

1.0.0(2y ago)080MITPHPPHP ^7.3|^8.0

Since Nov 9Pushed 2y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

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

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

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

[](#installation)

```
composer require dfware/sentry
```

Add target class in the application config:

```
return [
    'components' => [
	    'log' => [
		    'traceLevel' => YII_DEBUG ? 3 : 0,
		    'targets' => [
			    [
				    'class' => 'dfware\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' => 'dfware\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');
```

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

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

920d ago

### Community

Maintainers

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

---

Top Contributors

[![devpastetOLD](https://avatars.githubusercontent.com/u/16385834?v=4)](https://github.com/devpastetOLD "devpastetOLD (2 commits)")

---

Tags

sentryyii2

###  Code Quality

TestsCodeception

### Embed Badge

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

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