PHPackages                             jns/xhprof-bundle - 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. jns/xhprof-bundle

AbandonedArchivedSymfony-bundle[Debugging &amp; Profiling](/categories/debugging)

jns/xhprof-bundle
=================

Symfony JnsXhprofBundle

v1.1.0(10y ago)208472.9k↓50%46[8 issues](https://github.com/jonaswouters/XhprofBundle/issues)[1 PRs](https://github.com/jonaswouters/XhprofBundle/pulls)1MITPHPPHP &gt;=5.3.2

Since Jun 6Pushed 9y ago9 watchersCompare

[ Source](https://github.com/jonaswouters/XhprofBundle)[ Packagist](https://packagist.org/packages/jns/xhprof-bundle)[ Docs](https://github.com/jonaswouters/XhprofBundle)[ RSS](/packages/jns-xhprof-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (8)Used By (1)

README
======

[](#readme)

[![Build Status](https://camo.githubusercontent.com/6829c592c04bd81d148f497f436713f09cb4bc2750c66708792c3cda246c263c/68747470733a2f2f7472617669732d63692e6f72672f6a6f6e6173776f75746572732f586870726f6642756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jonaswouters/XhprofBundle) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/36d8a7432b2a6f8a7c76b61895ae159547f3f603a1a4d17a08600774a5a86ed0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f6e6173776f75746572732f586870726f6642756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jonaswouters/XhprofBundle/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/a87967bb6c63462b667a3600b1f9e038eddf96b14d11ffbb2bd07427649355ba/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f6e6173776f75746572732f586870726f6642756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jonaswouters/XhprofBundle/?branch=master)

What is XHProf?
---------------

[](#what-is-xhprof)

XHProf is a hierarchical profiler for PHP. It reports function-level call counts and inclusive and exclusive metrics such as wall (elapsed) time, CPU time and memory usage. A function's profile can be broken down by callers or callees. The raw data collection component is implemented in C as a PHP Zend extension called xhprof. XHProf has a simple HTML based user interface (written in PHP). The browser based UI for viewing profiler results makes it easy to view results or to share results with peers. A callgraph image view is also supported.

See [official documentation](http://php.net/manual/book.xhprof.php)

What does this Symfony 2 Bundle do?
-----------------------------------

[](#what-does-this-symfony-2-bundle-do)

This bundle helps you to easily use the XHProf bundle with the web debug toolbar in Symfony 2. With Symfony 2.3 and newer, it can also profile console commands.

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

[](#installation)

Make sure you have XHProf installed. If you are on a mac you can easily install it via [Macports](http://www.macports.org/)sudo port install php5-xhprof

1. ### Composer

    [](#composer)

Add the following dependencies to your projects composer.json file:

```
```json
"require": {
    "jns/xhprof-bundle": "1.0.*@dev",
    "lox/xhprof": "dev-master@dev"
}
```

```

Of course, you have to install [xhprof library](http://php.net/manual/fr/book.xhprof.php) in your server. At this moment, `ext-xhprof` is not required because your application could be deployed to a server without xhprof.

2. ### Old way by adding to your vendor/bundles/ dir

    [](#old-way-by-adding-to-your-vendorbundles-dir)
3. #### To install the bundle, place it in the `src/Jns/Bundle` directory of your project

    [](#to-install-the-bundle-place-it-in-the-srcjnsbundle-directory-of-your-project)

(so that it lives at `src/Jns/Bundle/XhprofBundle`). You can do this by adding the bundle as a submodule, cloning it, or simply downloading the source.

```
```bash
$ git submodule add https://github.com/jonaswouters/XhprofBundle.git src/Jns/Bundle/XhprofBundle
```

```

2. #### Add the Jns namespace to your autoloader

    [](#add-the-jns-namespace-to-your-autoloader)

```
If this is the first Jns bundle in your Symfony 2 project, you'll

```

need to add the `Jns` namespace to your autoloader. This file is usually located at `app/autoload.php`.

```
```php
$loader->registerNamespaces(array(
    'Jns' => __DIR__.'/../src'
    // ...
));
```

```

### Initializing the bundle

[](#initializing-the-bundle)

To initialize the bundle, you'll need to add it in your kernel. This file is usually located at `app/AppKernel.php`. Loading it only in your dev environment is recommended.

```
public function registerBundles()
{
    // ...

    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        // ...
        $bundles[] = new Jns\Bundle\XhprofBundle\JnsXhprofBundle();
    }
}
```

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

[](#configuration)

### Configure the XHProf locations.

[](#configure-the-xhprof-locations)

The Bundle comes preconfigured for the macports php5-xhprof default installation, with the xhprof web located at . To change these settings for your environment you can override the defaults by defining the following settings in your config. The config is usually located at `app/config/config_dev.yml`.

```
jns_xhprof:
    location_web:    http://xhprof.localhost
    enabled:         true
```

Do not forget to set `enabled` to `true`, or the profiler will never be activated.

### Using XHGui

[](#using-xhgui)

[XHGui](https://github.com/preinheimer/xhprof) is a GUI for the XHProf PHP extension, using a database backend, and pretty graphs to make it easy to use and interpret. The XHProf bundle supports using XHGui to display the results. To use, install XHGui, and add the following two settings to the configuration, usually located at `app/config/config.yml`:

```
jns_xhprof:
    entity_manager:   (defaults to default)
    entity_class:    Acme\FooBundle\Entity\XhprofDetail
    enable_xhgui:    true
```

Create your class `Acme\FooBundle\Entity\XhprofDetail`:

```
