PHPackages                             perfbase/yii1 - 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/yii1

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

perfbase/yii1
=============

Yii 1.1 integration for the Perfbase profiling tool.

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

Since Apr 8Pushed 4w agoCompare

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

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

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

### Perfbase for Yii 1.1

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

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

 [![Packagist Version](https://camo.githubusercontent.com/ab2976851c7202e0a6895bf0d69c7456a4895692ac49be841583fd07153a2551/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70657266626173652f79696931)](https://packagist.org/packages/perfbase/yii1) [![License](https://camo.githubusercontent.com/4c84998c2b9563e9727032aad9df4f9bb057c95d9d8b7c157a3633c0795fc053/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70657266626173652f79696931)](https://github.com/perfbaseorg/yii1/blob/main/LICENSE.txt) [![CI](https://camo.githubusercontent.com/edfe1887d8c0c9f3a14ed0efcad30d2b256ee5e62f23b0aa8abe94af2ccb95f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70657266626173656f72672f796969312f63692e796d6c3f6272616e63683d6d61696e)](https://github.com/perfbaseorg/yii1/actions/workflows/ci.yml) [![PHP Version](https://camo.githubusercontent.com/1150142271e92a6b30ce3ef37f5548f25d15d1e9cd200eea972f746cc7a2c40a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e342532422d626c7565)](https://camo.githubusercontent.com/1150142271e92a6b30ce3ef37f5548f25d15d1e9cd200eea972f746cc7a2c40a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e342532422d626c7565) [![Yii Version](https://camo.githubusercontent.com/e9e97378a44cb450159c2fbe49dbca296d53bf0b79f70f68a691c3b748991a01/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7969692d312e312e782d626c7565)](https://camo.githubusercontent.com/e9e97378a44cb450159c2fbe49dbca296d53bf0b79f70f68a691c3b748991a01/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7969692d312e312e782d626c7565)

This package is a thin adapter over [`perfbase/php-sdk`](https://packagist.org/packages/perfbase/php-sdk). It keeps the framework layer thin, delegates transport and extension access to the shared SDK, fails open in production, and keeps action naming low-cardinality.

Scope
-----

[](#scope)

v1 supports:

- HTTP request profiling
- Console command profiling
- Cron profiling as a classified console sub-context

v1 does not support:

- Queue workers
- Custom buffering or retries
- Yii-specific profiler UI or debug panels

This package is positioned as a legacy-support adapter for real Yii 1.1 applications.

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

[](#requirements)

- PHP `>=7.4  ['perfbase'],
    'components' => [
        'perfbase' => [
            'class' => \Perfbase\Yii1\PerfbaseComponent::class,
            'enabled' => true,
            'api_key' => getenv('PERFBASE_API_KEY') ?: '',
            'sample_rate' => 0.1,
            'app_version' => '1.0.0',
        ],
    ],
];
```

Composer-based installation is required. Non-Composer Yii 1.1 applications are out of scope.

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

[](#configuration)

The adapter exposes this config contract:

```
[
    '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' => ['*'],
        'cron' => [],
    ],
    'exclude' => [
        'http' => [],
        'console' => [],
        'cron' => [],
    ],
]
```

Config notes:

- `enabled` controls Perfbase profiling, not Yii component loading.
- `include.cron` is empty by default. That means console commands profile as `source=console` unless you explicitly classify them as cron.
- `sample_rate` must be numeric and 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.
- `app_version` is application-defined.
- `environment` is derived from `YII_ENV` when available, otherwise `production`.

HTTP Profiling
--------------

[](#http-profiling)

HTTP profiling is attached through Yii 1.1 application events:

- `onBeginRequest` starts the HTTP lifecycle
- `onException` and `onError` attach exception context
- `onEndRequest` finalizes and submits

Attributes include:

- `source=http`
- `action`
- `http_method`
- `http_url`
- `http_status_code`
- `user_ip`
- `user_agent`
- `user_id` when Yii user state is available and authenticated
- `hostname`
- `environment`
- `app_version`
- `php_version`

Behavior details:

- `action` prefers a stable Yii route
- `http_url` excludes query strings
- HTTP traces are only submitted when the response status code is in `profile_http_status_codes`
- query parameters are intentionally not included in the primary action/span fields
- response status defaults to `200` when Yii has not set a more specific status

Console and Cron Profiling
--------------------------

[](#console-and-cron-profiling)

Console profiling also uses application lifecycle hooks:

- `onBeginRequest` resolves the console command from `$_SERVER['argv']`
- `onException` and `onError` mark failures
- `onEndRequest` finalizes and submits

Console behavior:

- normal console commands use `source=console`
- commands matching `include.cron` and not matching `exclude.cron` use `source=cron`
- span names are `console.{command}` or `cron.{command}`
- exit code handling is best-effort and intentionally thin:
    - `0` on normal completion
    - `1` on uncaught exception or error paths

Cron is just a classification of console commands. There is no scheduler-specific integration in v1.

Filters
-------

[](#filters)

Each context supports include/exclude filters:

- `http`
- `console`
- `cron`

Supported filter styles:

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

Examples:

```
'include' => [
    'http' => ['site/*', '/^GET \\/api\\//'],
    'console' => ['cache/*', 'migrate'],
    'cron' => ['schedule/*', 'jobs/run'],
],
'exclude' => [
    'http' => ['debug/*'],
    'console' => ['help'],
    'cron' => ['schedule/test'],
],
```

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

[](#error-handling)

The adapter is designed to fail open:

- if SDK construction fails, profiling becomes a no-op
- if the extension is unavailable, profiling becomes a no-op
- if submission fails, the application continues

Error mode behavior:

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

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

[](#runtime-architecture)

The package stays intentionally thin:

- [`PerfbaseComponent.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii1/src/PerfbaseComponent.php) owns config and lazy service creation
- [`PerfbaseBootstrap.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii1/src/PerfbaseBootstrap.php) wires Yii application events
- lifecycle classes under [`src/Lifecycle`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii1/src/Lifecycle) set context-specific attributes
- [`PerfbaseClientProvider.php`](/Users/ben/Projects/Perfbase/environment/projects/lib-yii1/src/Support/PerfbaseClientProvider.php) lazily builds the SDK client

The adapter does not implement a separate transport or persistence layer.

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

[](#development)

Install and verify with:

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

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/yii1/issues](https://github.com/perfbaseorg/yii1/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

PHP version history (2 changes)v1.0.0PHP &gt;=7.4 &lt;8.5

v1.0.1PHP &gt;=7.4 &lt;8.6

### 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 (7 commits)")

---

Tags

apmphpyiiyii1monitoringprofilingapmyiiYii1Perfbase

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[scoutapp/scout-apm-laravel

Scout Application Performance Monitoring Agent - https://scoutapm.com

23838.1k](/packages/scoutapp-scout-apm-laravel)[scoutapp/scout-apm-php

Scout Application Performance Monitoring Agent - https://scoutapm.com

17885.0k5](/packages/scoutapp-scout-apm-php)[baibaratsky/yii2-rollbar

Rollbar for Yii2

35131.9k](/packages/baibaratsky-yii2-rollbar)[sobanvuex/php-newrelic

PHP Library for New Relic Agent

16520.7k5](/packages/sobanvuex-php-newrelic)[upscale/swoole-newrelic

New Relic APM monitoring of Swoole web-server

1619.7k](/packages/upscale-swoole-newrelic)

PHPackages © 2026

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