PHPackages                             perfbase/yii3 - 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. perfbase/yii3

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

perfbase/yii3
=============

Yii 3 integration for the Perfbase profiling tool.

v1.1.1(4w ago)12↓100%Apache-2.0PHPPHP &gt;=8.2 &lt;8.5CI passing

Since Apr 8Pushed 4w agoCompare

[ Source](https://github.com/perfbaseorg/yii3)[ Packagist](https://packagist.org/packages/perfbase/yii3)[ Docs](https://github.com/perfbaseorg/yii3)[ RSS](/packages/perfbase-yii3/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (12)Versions (5)Used By (0)

 [ ![Perfbase](https://camo.githubusercontent.com/a4e071fd1246cf5c68819015801139400d74b208b76a07ba8c5945d6e4ffd3ba/68747470733a2f2f63646e2e70657266626173652e636f6d2f696d672f6c6f676f2d66756c6c2e737667) ](https://perfbase.com)

### Perfbase for Yii 3

[](#perfbase-for-yii-3)

 Yii 3 integration for [Perfbase](https://perfbase.com).

 [![Packagist Version](https://camo.githubusercontent.com/ab66015c8b80a096e7db730c65e86dc0f276b722703ffa219e3ecc2a0a33eff0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70657266626173652f79696933)](https://packagist.org/packages/perfbase/yii3) [![License](https://camo.githubusercontent.com/0b49413cb26c204d130b4b90cfc633e921c059515d65f1f334fdfa63537a64f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70657266626173652f79696933)](https://github.com/perfbaseorg/yii3/blob/main/LICENSE.txt) [![CI](https://camo.githubusercontent.com/f182329465c6bbf4a9747b2f2e8d0bb1ddd29506cb34ba19f644e584216f80cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70657266626173656f72672f796969332f63692e796d6c3f6272616e63683d6d61696e)](https://github.com/perfbaseorg/yii3/actions/workflows/ci.yml) [![PHP Version](https://camo.githubusercontent.com/351755b1ea3b8a079461d461cd8142582eb91df14fea214307a660632576b07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d626c7565)](https://camo.githubusercontent.com/351755b1ea3b8a079461d461cd8142582eb91df14fea214307a660632576b07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d626c7565) [![Yii Version](https://camo.githubusercontent.com/55ecc85499841bee317243ea65b7999e28f6d124bbd0f7cd87f9f2f792872354/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7969692d332e782d626c7565)](https://camo.githubusercontent.com/55ecc85499841bee317243ea65b7999e28f6d124bbd0f7cd87f9f2f792872354/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7969692d332e782d626c7565)

This package is a thin adapter over [`perfbase/php-sdk`](https://packagist.org/packages/perfbase/php-sdk). It keeps the framework layer thin and pushes transport, extension access, and submission behavior into the shared SDK.

Scope
-----

[](#scope)

v1 supports:

- HTTP profiling through PSR-15 middleware
- Console command profiling through Symfony Console events

v1 does not support:

- Queue or worker profiling
- Scheduler-specific profiling
- Custom buffering or retries
- Yii-specific profiler UI

Requirements
------------

[](#requirements)

- PHP `>=8.1  [
        'enabled' => true,
        'api_key' => $_ENV['PERFBASE_API_KEY'] ?? '',
        'sample_rate' => 0.1,
        'app_version' => '1.0.0',
    ],
];
```

Configuration
-------------

[](#configuration)

The config provider exposes this default config under `params['perfbase']`:

```
[
    'enabled' => false,
    'debug' => false,
    'log_errors' => true,
    'api_key' => '',
    'api_url' => 'https://ingress.perfbase.cloud',
    'sample_rate' => 0.1,
    'profile_http_status_codes' => [...range(200, 299), ...range(500, 599)],
    'timeout' => 10,
    'proxy' => null,
    'flags' => \Perfbase\SDK\FeatureFlags::DefaultFlags,
    'app_version' => '',
    'include' => [
        'http' => ['*'],
        'console' => ['*'],
    ],
    'exclude' => [
        'http' => [],
        'console' => [],
    ],
]
```

Notes:

- `sample_rate` must be numeric between `0.0` and `1.0`
- `profile_http_status_codes` defaults to `[...range(200, 299), ...range(500, 599)]`. Add codes such as `404` if you want to keep them, or set it to `[]` to disable HTTP trace submission entirely.
- `environment` comes from `YII_ENV`, otherwise `production`
- `app_version` is application-defined

HTTP Integration
----------------

[](#http-integration)

HTTP profiling is middleware-based through [`PerfbaseHttpMiddleware.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/Middleware/PerfbaseHttpMiddleware.php).

Register it in your HTTP middleware pipeline:

```
use Perfbase\Yii3\Middleware\PerfbaseHttpMiddleware;

return [
    PerfbaseHttpMiddleware::class,
    // other middleware...
];
```

Behavior:

- starts profiling before delegating to the next handler
- captures response status on success
- captures exception context on failure
- HTTP traces are only submitted when the response status code is in `profile_http_status_codes`
- always stops profiling in `finally`

HTTP attributes include:

- `source=http`
- `action`
- `http_method`
- `http_url`
- `http_status_code`
- `user_ip`
- `user_agent`
- `hostname`
- `environment`
- `app_version`
- `php_version`

Route metadata behavior:

- route template is resolved from request attributes such as `routePattern`, `route`, or `_route`
- route name is resolved from `routeName` or `route_name`
- controller metadata is resolved from `controller` or `action`
- `http_url` excludes query strings

Console Integration
-------------------

[](#console-integration)

Console profiling is wired through [`ConsoleProfilerSubscriber.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/EventSubscriber/ConsoleProfilerSubscriber.php), which subscribes to Symfony Console events used by Yii3 console packages.

Register the subscriber with your event dispatcher:

```
use Perfbase\Yii3\EventSubscriber\ConsoleProfilerSubscriber;
use Symfony\Component\EventDispatcher\EventDispatcher;

$dispatcher = $container->get(EventDispatcher::class);
$dispatcher->addSubscriber($container->get(ConsoleProfilerSubscriber::class));
```

Subscribed events:

- `ConsoleEvents::COMMAND`
- `ConsoleEvents::ERROR`
- `ConsoleEvents::TERMINATE`

Behavior:

- lifecycles are keyed by the input object identity
- exceptions are attached on `ERROR`
- exit codes are attached on `TERMINATE`
- lifecycle state is cleaned up even when command execution fails

Filters
-------

[](#filters)

Supported contexts:

- `http`
- `console`

Supported filter styles:

- `*`
- `.*`
- glob patterns such as `cache/*`
- regex patterns such as `/^GET \/api\//`

Example:

```
'perfbase' => [
    'include' => [
        'http' => ['route/*', '/^GET \\/api\\//'],
        'console' => ['cache/*', 'migrate'],
    ],
    'exclude' => [
        'http' => ['debug/*'],
        'console' => ['help'],
    ],
],
```

Error Handling
--------------

[](#error-handling)

The adapter is fail-open:

- SDK init failures degrade to a no-op
- missing extension degrades to a no-op
- submit failures do not break request or command execution

Behavior:

- `debug=false`: swallow and optionally log errors
- `debug=true`: rethrow adapter/runtime errors

Runtime Architecture
--------------------

[](#runtime-architecture)

Primary entry points:

- [`ConfigProvider.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/ConfigProvider.php)
- [`PerfbaseHttpMiddleware.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/Middleware/PerfbaseHttpMiddleware.php)
- [`ConsoleProfilerSubscriber.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/EventSubscriber/ConsoleProfilerSubscriber.php)
- lifecycle classes in [`src/Lifecycle`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/Lifecycle)
- support helpers in [`src/Support`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii3/src/Support)

The adapter does not implement its own delivery layer.

Development
-----------

[](#development)

Verify locally with:

```
composer install
composer run test
composer run phpstan
```

Limitations
-----------

[](#limitations)

- No queue support in v1
- No scheduler-specific integration in v1
- No Yii-specific debug toolbar integration
- HTTP and console wiring must be registered explicitly in the host application

Documentation
-------------

[](#documentation)

Full documentation is available at [perfbase.com/docs](https://perfbase.com/docs).

- **Docs**: [perfbase.com/docs](https://perfbase.com/docs)
- **Issues**: [github.com/perfbaseorg/yii3/issues](https://github.com/perfbaseorg/yii3/issues)
- **Support**:

License
-------

[](#license)

Apache-2.0. See [LICENSE.txt](LICENSE.txt).

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

Every ~11 days

Total

4

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85d93938cbda24f3ae1b325d2c1ac89e95f1f845365395a693bad51e8b61b5d9?d=identicon)[BenPoulson](/maintainers/BenPoulson)

---

Top Contributors

[![benpoulson](https://avatars.githubusercontent.com/u/1797843?v=4)](https://github.com/benpoulson "benpoulson (9 commits)")

---

Tags

apmphpyii3monitoringprofilingapmyii3Perfbase

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/perfbase-yii3/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[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)[typo3/cms-core

TYPO3 CMS Core

3312.9M4.7k](/packages/typo3-cms-core)[yiisoft/app

Yii3 web application template

36813.9k](/packages/yiisoft-app)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)[yiisoft/app-api

Yii3 API project template

1031.7k](/packages/yiisoft-app-api)

PHPackages © 2026

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