PHPackages                             macfly/yii2-tracker - 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. macfly/yii2-tracker

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

macfly/yii2-tracker
===================

Yii2 component to to track request for along all microservices app

0.2.6(6y ago)328.6k—5.9%BSD-3-ClausePHP

Since Sep 6Pushed 6y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (10)Used By (0)

yii2-tracker
============

[](#yii2-tracker)

Yii2 tracker try to get or set a unique request id for every request to follow it from service to service mainly for logging, debuging and track which micro-service is doing what on other micro-service app.

Component will try to get from :

- From every [HTTP request](http://www.yiiframework.com/doc-2.0/guide-runtime-requests.html) the header with name @X-tracker-request-id@, it means that we have been call by another service which already provide us a unique request id
- From RabbitMQ message header, currently working with [mikemadisonweb/yii2-rabbitmq extension](https://github.com/mikemadisonweb/yii2-rabbitmq)
- If no unique request id is provide create one it means we're the first micro-service to be call
- If we're doing request to API through [yiisoft/yii2-httpclient](https://github.com/yiisoft/yii2-httpclient/) add the @X-tracker-request-id@ to outgoing request
- If we're sending RabbitMQ message add to every message a header @X-tracker-request-id@, working with version 2.x of [mikemadisonweb/yii2-rabbitmq extension](https://github.com/mikemadisonweb/yii2-rabbitmq/)
- Add header @X-tracker-request-id@ in every [HTTP response](http://www.yiiframework.com/doc-2.0/guide-runtime-responses.html)

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

[](#installation)

The preferred way to install this component is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist "macfly/yii2-tracker" "*"

```

or add to the @require@ section in your `composer.json` file.

```
"macfly/yii2-tracker": "*"

```

Configure
---------

[](#configure)

Configure **config/web.php** and **config/console.php** as follows

```
'bootstrap'     => [
    'log',
    'tracker',
],
'components'    => [
    'tracker'   => [
        'class'  => 'app\components\Tracker',
        'header' => 'X-tracker-request-id', // Name of the header component try to get or set.
    ],
    ................
],
```

Usage
-----

[](#usage)

You can get the unique request id from the component with :

```
 \Yii::$app->tracker->id;
```

For example if you want to add it to your log you can change the the target prefix to :

```
'components' => [
    'log' => [
        'targets' => [
            [
                'class'   => 'yii\log\FileTarget',
                'logVars' => [],
                'prefix' => function ($message) {
                    if (Yii::$app === null) {
                        return '';
                    }

                    $app = Yii::$app->name;
                    $id = Yii::$app->tracker->getId();
                    $request = Yii::$app->getRequest();
                    $ip = $request instanceof Request ? $request->getUserIP() : '-';
                    /* @var $user \yii\web\User */
                    $user = Yii::$app->has('user', true) ? Yii::$app->get('user') : null;
                    if ($user && ($identity = $user->getIdentity(false))) {
                        $userID = $identity->getId();
                    } else {
                        $userID = '-';
                    }
                    /* @var $session \yii\web\Session */
                    $session = Yii::$app->has('session', true) ? Yii::$app->get('session') : null;
                    $sessionID = $session && $session->getIsActive() ? $session->getId() : '-';

                    return "[$app][$id][$ip][$userID][$sessionID]";
                },
            ],
        ],
    ],
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~92 days

Recently: every ~179 days

Total

9

Last Release

2441d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/74924cc29f67eef7ca7640876dd3462974466ea683f8d059c70a33b3087d7230?d=identicon)[Macfly](/maintainers/Macfly)

---

Top Contributors

[![djerfy](https://avatars.githubusercontent.com/u/2886596?v=4)](https://github.com/djerfy "djerfy (2 commits)")[![marty-macfly](https://avatars.githubusercontent.com/u/12715929?v=4)](https://github.com/marty-macfly "marty-macfly (1 commits)")

---

Tags

requestlogdebugservertrackingyii2

### Embed Badge

![Health badge](/badges/macfly-yii2-tracker/health.svg)

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

###  Alternatives

[baibaratsky/yii2-rollbar

Rollbar for Yii2

35130.5k](/packages/baibaratsky-yii2-rollbar)

PHPackages © 2026

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