PHPackages                             renansaddam/cakephp-xhprof-plugin - 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. renansaddam/cakephp-xhprof-plugin

Abandoned → [renan/cakephp-xhprof](/?search=renan%2Fcakephp-xhprof)Cakephp-plugin[Debugging &amp; Profiling](/categories/debugging)

renansaddam/cakephp-xhprof-plugin
=================================

Plugin that quickly enables XHProf profiling for your CakePHP application.

v1.0.0(11y ago)211132[1 issues](https://github.com/renan/CakePHP-XHProf/issues)MITPHPPHP &gt;=5.3

Since Nov 3Pushed 10y ago2 watchersCompare

[ Source](https://github.com/renan/CakePHP-XHProf)[ Packagist](https://packagist.org/packages/renansaddam/cakephp-xhprof-plugin)[ Docs](http://github.com/renan/CakePHP-XHProf)[ RSS](/packages/renansaddam-cakephp-xhprof-plugin/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

CakePHP XHProf Plugin
=====================

[](#cakephp-xhprof-plugin)

[![Build Status](https://camo.githubusercontent.com/68e83c79e8e3f14e78ac940eda551f56e9916f9d88f412933e72dd3d11120bda/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f72656e616e2f43616b655048502d584850726f662e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/renan/CakePHP-XHProf)[![Coverage Status](https://camo.githubusercontent.com/ba42a4e6d512c64f1e61263ff7f636ecbd53eef8f7fb5b239deb7093f9e8ed37/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f72656e616e2f43616b655048502d584850726f662f62616467652e706e67)](https://coveralls.io/r/renan/CakePHP-XHProf)[![Latest Stable Version](https://camo.githubusercontent.com/aecec6abee690411f5c314054105a8b7bbfe211451cd528223de4ffad4c26de8/68747470733a2f2f706f7365722e707567782e6f72672f72656e616e2f63616b657068702d786870726f662f762f737461626c652e737667)](https://packagist.org/packages/renan/cakephp-xhprof)

Plugin that quickly enables XHProf profiling for your CakePHP application.

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

[](#requirements)

- PHP 5.3+
- CakePHP 2.3+
- XHProf

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

[](#installation)

First, make sure you enabled the xhprof extension and downloaded [phacility/xhprof](https://github.com/phacility/xhprof).

### Manual

[](#manual)

1. Download
2. Unzip the downloaded file
3. Move the contents to `Plugin/XHProf`

### Git Submodule

[](#git-submodule)

```
git submodule add git://github.com/renan/CakePHP-XHProf.git Plugin/XHProf
git submodule update --init
```

### Git Clone

[](#git-clone)

```
git clone git://github.com/renan/CakePHP-XHProf.git Plugin/XHProf
```

### Composer / Packagist

[](#composer--packagist)

Extra information can be found at [Packagist](https://packagist.org/packages/renan/cakephp-xhprof).

This would install the latest 0.1 version to `Plugin/XHProf`:

```
{
	"require": {
		"renan/cakephp-xhprof": "0.1.*"
	}
}
```

You might want to use "require-dev" if you only plan to use this for development.

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

[](#configuration)

The basic configuration consists of loading the plugin and pointing where the `xhprof_lib` directory is located on your system.

On your `Config/bootstrap.php` file:

```
// Load XHProf Plugin
CakePlugin::load('XHProf');

// XHProf Configuration
Configure::write('XHProf', array(
	'library' => '/usr/local/Cellar/php54-xhprof/270b75d/xhprof_lib',
));
```

Options:

- `library`: Path to your xhprof\_lib directory (required)
- `namespace`: Namespace to save your xhprof runs, default is your application directory name
- `flags`: Flags passed over to profiler, default is `0`. For a list of flags visit:
- `ignored_functions`: Array of functions to ignore, default is `call_user_func` and `call_user_func_array`
- `replaceRunId`: Placeholder used to replace the run id in order to display a link in the page, set `false` to disable, default is `%XHProfRunId%`. Read the usage for more information

All options example:

```
Configure::write('XHProf', array(
	'library' => '/usr/local/Cellar/php54-xhprof/270b75d/xhprof_lib',
	'namespace' => 'myapp',
	'flags' => XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY,
	'ignored_functions' => array(
		'my_function',
		'my_other_function',
	),
	'replaceRunId' => false,
));
```

Usage
-----

[](#usage)

### Dispatcher Filter

[](#dispatcher-filter)

Just include the `XHProfDispatcher` in your dispatcher filters list on `Config/bootstrap.php`:

```
Configure::write('Dispatcher.filters.xhprof', 'XHProf.XHProfDispatcher');
```

By default it will try to replace `%XHProfRunId%` with the saved run id from the page's output. It allows you to include a link to the xhprof report on the page.

On your `View/Layouts/default.ctp`:

```
$url = sprintf(
	'/url/to/xhprof_html/index.php?run=%s&source=%s',
	Configure::read('XHProf.replaceRunId'),
	Configure::read('XHProf.namespace')
);
echo $this->Html->link('XHProf Output', $url);
```

#### DebugKit Panel

[](#debugkit-panel)

If you are using [DebugKit](https://github.com/cakephp/debug_kit), you can use the provided panel here.

Make sure you include html config of the URL endpoint of the xhprof\_html folder:

```
Configure::write('XHProf', array(
	'library' => '/usr/local/Cellar/php54-xhprof/270b75d/xhprof_lib',
	'html' => 'http://path/to/xhprof_html',
));
```

Then you can add the panel in your DebugKit components setup:

```
public $components = array(
	'DebugKit.Toolbar' => array(
		'panels' => array('XHProf.XHProf')
	),
);
```

Done. It should now display the new panel with the link to the result of this page output.

### Manual

[](#manual-1)

This method is very useful when profiling specific points on your code. For that, just use the `XHProf` class to assist you.

Example:

```
// Declare the class location
App::uses('XHProf', 'XHProf.Lib');

// Start the profiler
XHProf::start();

// ... your application code

// Stop the profiler
// 1. Returning the profiler data
$data = XHProf::stop();

// 2. or Save the profiler data, returning the run id
$runId = XHProf::finish();
```

*Note*: There are two ways to stop the profiler as explained above. However only one can be used at each run.

Changelog
---------

[](#changelog)

### 1.0.0 (2014-09-30)

[](#100-2014-09-30)

- Added a DebugKit panel instead of messing with the layout file. Thanks to @dereuromark for the patch.
- Collecting code coverage metrics and reporting to coveralls

### 0.1.0 (2012-11-03)

[](#010-2012-11-03)

Initial release

License
-------

[](#license)

Copyright (c) 2014 Renan Gonçalves

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

4246d ago

Major Versions

0.1.0 → v1.0.02014-09-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/77f9d59d672d2ecdd3f8e4aabde96848946f7933c5b1342d8bec82bb73f7f8a4?d=identicon)[renan.saddam](/maintainers/renan.saddam)

---

Top Contributors

[![renan](https://avatars.githubusercontent.com/u/28046?v=4)](https://github.com/renan "renan (26 commits)")

---

Tags

debugprofilingcakephpxhprof

### Embed Badge

![Health badge](/badges/renansaddam-cakephp-xhprof-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/renansaddam-cakephp-xhprof-plugin/health.svg)](https://phpackages.com/packages/renansaddam-cakephp-xhprof-plugin)
```

###  Alternatives

[barryvdh/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k124.3M624](/packages/barryvdh-laravel-debugbar)[renan/cakephp-xhprof

Plugin that quickly enables XHProf profiling for your CakePHP application.

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

Easy XHProf setup to profile your laravel application!

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

Quick profiling of your code for Laravel

22156.6k](/packages/bavix-laravel-xhprof)[sandstorm/plumber

Profiling Toolkit for Neos Flow and Neos

384.9k](/packages/sandstorm-plumber)

PHPackages © 2026

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