PHPackages                             cltv/yii3sentry - 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. cltv/yii3sentry

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

cltv/yii3sentry
===============

1.0.2(3y ago)02BSD-3-ClausePHPPHP ^8.0

Since Aug 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/gluck1986/yii3sentry)[ Packagist](https://packagist.org/packages/cltv/yii3sentry)[ RSS](/packages/cltv-yii3sentry/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (14)Versions (4)Used By (0)

This implementation sentry tracing using logs.

**Install**

**for gitlab**

you should add the repository to your project

```
    composer config repositories./109 '{"type": "composer", "url": "https:///api/v4/group/109/-/packages/composer/packages.json"}'
```

---

if you have the error 404 you should add auth.json into composer.json directory by command and add this file to .gitignore

```
    composer config gitlab-token.
```

---

**Configure:**

add code block below to your params.php and type your DSN also you can define your environment and release, for example TAG from gitlab.ci

```
    'sentry' =>
        [
            'options' => [
                'dsn' => '',
                'environment' => 'local', //SENTRY_ENVIRONMENT, //YII_ENV,
                'release' => 'dev',  //SENTRY_RELEASE, //TAG
                // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii
                'send_default_pii' => true,
                'traces_sample_rate' => 1.0,
            ],
            'log_level' => 'warning',
            'tracing'          => [
                // Indicates if the tracing integrations supplied by Sentry should be loaded
                'default_integrations'   => true,
            ],
        ]
```

add APP\_START\_TIME const into index.php and yii.php

```
define('APP_START_TIME', microtime(true));
```

add log targets for breadcrumbs and tracing in app/config/common/logger.php or another config file with logger settings

```
return [
    LoggerInterface::class => static function (
        /** your_another_log_target $your_log_target */
        \Webvork\Yii3\Sentry\SentryBreadcrumbLogTarget $sentryLogTarget,
        \Webvork\Yii3\Sentry\Tracing\SentryTraceLogTarget $sentryTraceLogTarget
    ) {
        return new Logger([
        /** $your_log_target */
            $sentryLogTarget,
            $sentryTraceLogTarget
        ]);
    }
];
```

**if you want to see your logs in sentry timeline**, you need to use keys (float)'**time**' and (float)'**elapsed**' in log context array

---

add DB log decorator for tracing db queries in app/config/params.php

```
'yiisoft/yii-cycle' => [
        // DBAL config
        'dbal' => [
            // SQL query logger. Definition of Psr\Log\LoggerInterface
            // For example, \Yiisoft\Yii\Cycle\Logger\StdoutQueryLogger::class
            'query-logger' => \Webvork\Yii3\Sentry\DbLoggerDecorator::class,
            /**
            * ...
            * your another db settings
            **/
    ]
]
```

add into app/config/params.php into middleware section SetRequestIpMiddleware

```
    'middlewares' => [
        ErrorCatcher::class,
        Webvork\Yii3\Sentry\Http\SetRequestIpMiddleware::class, //add this
        Router::class,
    ],
```

add into app/config/common/router.php tracing middleware

```
  RouteCollectionInterface::class => static function (RouteCollectorInterface $collector) use ($config) {
        $collector
            ->middleware(FormatDataResponse::class)
            ->middleware(JsonParseMiddleware::class)
            ->middleware(ExceptionMiddleware::class)
            ->middleware(\Webvork\Yii3\Sentry\Tracing\SentryTraceMiddleware::class) // add this
            ->addGroup(
                Group::create('')
                    ->routes(...$config->get('routes'))
            );

        return new RouteCollection($collector);
    },
```

---

if you want to trace guzzle requests and add sentry headers to external queries, add this into your config\\httpClient.php or into another factories config file

```
    GuzzleHttp\Client::class => static function (ContainerInterface $container) {
        $stack = new HandlerStack();
        $stack->setHandler(new CurlHandler());
        $factory = $container->get(GuzzleMiddlewareFactory::class);
        $middleware = static function (callable $handler) use ($factory): callable {
            return $factory->factory($handler);
        };

        $stack->push($middleware);

        return new GuzzleHttp\Client([
            'handler' => $stack,
        ]);
    },
```

if your transaction too heavy you can slice it to several transactions with clearing log buffer.

use SentryConsoleTransactionAdapter or SentryWebTransactionAdapter

for example:

```
        /** some code with default transaction */
        /** commit default transaction and send data to sentry server */
        $sentryTraceString = $this->sentryTransactionAdapter->commit();
        while ($currentDate sentryTransactionAdapter->begin($sentryTraceString)
                ->setName('my_heavy_operation/iteration')
                ->setData(['date' => $currentDate->format('Y-m-d')]);

            $this->process($currentDate, $sentryTraceString);
            $this->sentryTransactionAdapter->commit();
        }
        $this->sentryTransactionAdapter->begin($sentryTraceString)
            ->setName('my_heavy_operation done, terminating application');
    /** transaction will commit when application is terminated */
```

for this example all new transactions will linked to transaction with $sentryTraceString

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Total

3

Last Release

1425d ago

### Community

Maintainers

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

---

Tags

sentryyii

###  Code Quality

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cltv-yii3sentry/health.svg)

```
[![Health](https://phpackages.com/badges/cltv-yii3sentry/health.svg)](https://phpackages.com/packages/cltv-yii3sentry)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M19.9k](/packages/laravel-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M418](/packages/drupal-core-recommended)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.1k](/packages/typo3-cms-core)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)

PHPackages © 2026

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