PHPackages                             imhelle/yii2-xhprof-lib - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. imhelle/yii2-xhprof-lib

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

imhelle/yii2-xhprof-lib
=======================

Simple extension to profile Yii Framework 2.x applications with XHProf

0.0.11(7y ago)039BSD-3-ClausePHPPHP &gt;=5.6.0

Since May 30Pushed 7y ago1 watchersCompare

[ Source](https://github.com/imhelle/yii2-xhprof-lib)[ Packagist](https://packagist.org/packages/imhelle/yii2-xhprof-lib)[ Docs](https://github.com/imhelle/yii2-xhprof-lib)[ RSS](/packages/imhelle-yii2-xhprof-lib/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (13)Used By (0)

yii2-xhprof
===========

[](#yii2-xhprof)

Simple extension to use XHProf with Yii Framework 2.x. This is the updated version of [yii-xhprof](https://github.com/imhelle/yii-xhprof) extension for Yii Framework 1.x.

Bundled with debug panel for official [yii2-debug](https://github.com/yiisoft/yii2-debug) extension.

By default profile starts during bootstrap process and stops in PHP shutdown function. You can change this behavior and manually start and stop profiler.

Tested on Yii Framework v2.0.6+.

Xhprof installation
-------------------

[](#xhprof-installation)

(CentOS)

```
sudo yum install gcc

cd /www/biglion/general/data/lib/vendor/imhelle/yii2-xhprof-lib/lib/
phpize
./configure
make
make test
sudo make install

sudo yum install graphviz

```

Yii extension installation
--------------------------

[](#yii-extension-installation)

This extension is available at [packagist.org](http://packagist.org/imhelle/yii2-xhprof) and can be installed via composer by following command:

`composer require --dev imhelle/yii2-xhprof`.

Minimal configuration to enable profiler:

```
return [
    'bootstrap' => [
        'xhprof'
    ],
    'components' => [
        'xhprof' => [
            'class' => 'imhelle\xhprof\XHProfComponent',
            'libPath' => '/full/path/to/xhprof_lib',
            'htmlReportBaseUrl' => 'http://url.to/xhprof_html',
        ],
    ],
];
```

To use bundled debug panel - update configuration next way:

```
return [
    'bootstrap' => [
        'debug',
        'xhprof'
    ],
    'components' => [
        'debug' => [
            // ... other debug config options ...
            'panels' => [
                'xhprof' => [
                    'class' => 'imhelle\xhprof\XHProfPanel'
                ]
            ]
        ],
    ],
];
```

*Note:* `xhprof` should be after `debug` in `preload` section to be able to ignore requests to debug module pages.

Required XHProf files (library files - `xhprof_lib` and UI - `xhprof_html`) you can find in this [GitHub repo](https://github.com/phacility/xhprof).

Component configuration
-----------------------

[](#component-configuration)

Extension provide next configuration options for Yii component:

- `enabled` - enable/disable profiler component.
- `reportPath` - filesystem path or path alias to the directory to store JSON file with previous profiler runs. Default: `@runtime/xhprof`
- `maxReportsCount` - number of profile reports to store. Default: `25`.
- `autoStart` - flag to automatically start profiler during application bootstrap process. Default: `true`.
- `autoStop` - flag to automatically stop profiler in PHP shutdown function. Default: `true`.
- `forceStop` - flag to force stop profiler during PHP shutdown if `autoStop` is disabled and profiler was manually started and is still running. Default: `true`.
- `triggerGetParam` - name of the GET param to manually trigger profiler to start. Default: no value, profiler runs on each request.
- `showOverlay` - flag to display overlay on page with links to report and callgraph result for current profiler run (if allowed). Not required to be `true` if you are using bundled panel for yii2-debug extension. Default: `true`.
- `libPath` - direct filesystem path or path alias to the directory with `xhprof_lib` contents.
- `htmlReportBaseUrl` - URL path to the directory with XHProf UI contents (`xhprof_html`). Default: `/xhprof_html` (assuming you have this folder inside your document root).
- `flagNoBuiltins` - enable/disable XHPROF\_FLAGS\_NO\_BUILTINS flag for profiler ([XHProf constants](http://php.net/manual/xhprof.constants.php)). Default: `true`.
- `flagCpu` - enable/disable XHPROF\_FLAGS\_CPU flag for profiler ([XHProf constants](http://php.net/manual/xhprof.constants.php)). Default: `false`.
- `flagMemory` - enable/disable XHPROF\_FLAGS\_MEMORY flag for profiler ([XHProf constants](http://php.net/manual/xhprof.constants.php)). Default: `true`.
- `ignoredFunctions` - list of functions to ignore during profiling. Empty by default. *Note*: this option is not supported by `tideways_xhprof` extension.
- `blacklistedRoutes` - list of routes which profiler should ignore. Allowed wildcard `*` which means 'any alphanumeric value and one of this: `/`, `.`, `_`, `-`. Default: `['debug*']` (to ignore requests to the debug extension pages).

XHProf class configuration
--------------------------

[](#xhprof-class-configuration)

Component from extension use own developed simple wrapper for `xhprof_enable` / `xhprof_disable` functions: [XHProf](XHProf.php) class. This class provide functionality to start/stop profiling, save reports and get URLs for reports with XHProf library by Facebook.

Available configuration options (applicable for `configure` method, see example below):

- `flagNoBuiltins` - enable/disable XHPROF\_FLAGS\_NO\_BUILTINS flag for profiler ([XHProf constants](http://php.net/manual/xhprof.constants.php)). Default: `true`.
- `flagCpu` - enable/disable XHPROF\_FLAGS\_CPU flag for profiler ([XHProf constants](http://php.net/manual/xhprof.constants.php)). Default: `false`.
- `flagMemory` - enable/disable XHPROF\_FLAGS\_MEMORY flag for profiler ([XHProf constants](http://php.net/manual/xhprof.constants.php)). Default: `true`.
- `ignoredFunctions` - list of functions to ignore during profiling ([xhprof\_enable() function](http://php.net/manual/ru/function.xhprof-enable.php)). Empty by default.
- `libPath` - direct filesystem path to the directory with `xhprof_lib` contents.
- `htmlUrlPath` - URL path to the directory with XHProf UI contents (`xhprof_html`).
- `runNamespace` - predefined value of namespace for current profiler run.

All options can be changed with setters (e.g. `setFlagCpu()`). For more details see the source code of the class.

Manual profiling
----------------

[](#manual-profiling)

If you disable auto start (`autoStart` option) or stop (`autoStop` option) you can place code to start/stop profiler in any place of your code and be able to see report and callgraph result via overlay or debug panel.

To manual start you need to write some kind of next code:

```
// create and configure instance of XHProf class
\imhelle\xhprof\XHProf::getInstance()->configure(array(
    'flagNoBuiltins' => true,
    'flagCpu' => false,
    'flagMemory' => true,
    'runNamespace' => 'my-cool-namespace',
    'libPath' => '/var/www/html/xhprof/xhprof_lib',
    'htmlUrlPath' => 'http://test.local/xhprof/xhprof_html'
));

// start profiler
\imhelle\xhprof\XHProf::getInstance()->run();
```

To manual stop you need to write next code:

```
// stop profiler and get URLs to results and callgraph
$urls = \imhelle\xhprof\XHProf::getInstance()->stop();

// Links:
// $urls[\imhelle\xhprof\XHProf::TYPE_REPORT]
// $urls[\imhelle\xhprof\XHProf::TYPE_CALLGRAPH]
```

*Note:* If you use `XHProf` class (with or without this extension) - all profile results can be found on XHProf UI page (it's by default by xhprof developers).

Note for PHP 7 and XHProf
-------------------------

[](#note-for-php-7-and-xhprof)

If you want to use this extension with PHP 7, you can use next forked version of xhprof extension: . This extension was tested on PHP 7.1.11 with extension built from provided repository.

Another better option - is to use officially ported xhprof extension by [tideways.io](https://tideways.io) - .

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~1 days

Total

11

Last Release

2889d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb8890c1fe4cc70beddea303794812b4a74350ed790cfb05d0df53b57dcfdffd?d=identicon)[sp-olga](/maintainers/sp-olga)

---

Top Contributors

[![imhelle](https://avatars.githubusercontent.com/u/11500481?v=4)](https://github.com/imhelle "imhelle (14 commits)")[![Stevad](https://avatars.githubusercontent.com/u/9192085?v=4)](https://github.com/Stevad "Stevad (11 commits)")[![jetexe](https://avatars.githubusercontent.com/u/4963272?v=4)](https://github.com/jetexe "jetexe (3 commits)")

---

Tags

debugprofilingyii2yiixhprof

### Embed Badge

![Health badge](/badges/imhelle-yii2-xhprof-lib/health.svg)

```
[![Health](https://phpackages.com/badges/imhelle-yii2-xhprof-lib/health.svg)](https://phpackages.com/packages/imhelle-yii2-xhprof-lib)
```

###  Alternatives

[laracraft-tech/laravel-xhprof

Easy XHProf setup to profile your laravel application!

235321.4k](/packages/laracraft-tech-laravel-xhprof)[renan/cakephp-xhprof

Plugin that quickly enables XHProf profiling for your CakePHP application.

2138.7k](/packages/renan-cakephp-xhprof)[bavix/laravel-xhprof

Quick profiling of your code for Laravel

22156.6k](/packages/bavix-laravel-xhprof)

PHPackages © 2026

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