PHPackages                             pshentsoff/xhgui - 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. pshentsoff/xhgui

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

pshentsoff/xhgui
================

A web based interface for viewing profile data collected by XHProf.

0.10.1(5y ago)04MITJavaScriptPHP ^5.6 || ^7.0

Since Dec 12Pushed 5y agoCompare

[ Source](https://github.com/pshentsoff/xhgui)[ Packagist](https://packagist.org/packages/pshentsoff/xhgui)[ RSS](/packages/pshentsoff-xhgui/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (7)Versions (9)Used By (0)

xhgui
=====

[](#xhgui)

A graphical interface for XHProf data built on MongoDB.

This tool requires that [XHProf](http://pecl.php.net/package/xhprof) or its one of its forks [Uprofiler](https://github.com/FriendsOfPHP/uprofiler), [Tideways](https://github.com/tideways/php-profiler-extension) are installed. XHProf is a PHP Extension that records and provides profiling data. XHGui (this tool) takes that information, saves it in MongoDB, and provides a convenient GUI for working with it.

[![Build Status](https://camo.githubusercontent.com/f12be5dc09a7eb98711358e74500834fa6b57982a1e497cb79f19f4b805aaa78/68747470733a2f2f7472617669732d63692e6f72672f707368656e74736f66662f78686775692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pshentsoff/xhgui)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/003a7cb2328d69aecccf71b7eb7228e8b95488862d1101a59e6d1e004eeed04f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f707368656e74736f66662f78686775692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/pshentsoff/xhgui/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a5c085fb16845bacea0250e5dfc6916136a6b6770259c8c6dcfc79d9580c6f8b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f707368656e74736f66662f78686775692f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/pshentsoff/xhgui/?branch=master)

System Requirements
===================

[](#system-requirements)

XHGui has the following requirements:

- PHP version 5.6 up to 7.3.
- [MongoDB Extension](http://pecl.php.net/package/mongodb) MongoDB PHP driver. XHGui requires verison 1.3.0 or later.
- [MongoDB](http://www.mongodb.org/) MongoDB Itself. XHGui requires version 2.2.0 or later.
- One of [XHProf](http://pecl.php.net/package/xhprof), [Uprofiler](https://github.com/FriendsOfPHP/uprofiler) or [Tideways](https://github.com/tideways/php-profiler-extension) to actually profile the data.
- [dom](http://php.net/manual/en/book.dom.php) If you are running the tests you'll need the DOM extension (which is a dependency of PHPUnit).

Installation from source
========================

[](#installation-from-source)

1. Clone or download `xhgui` from GitHub.
2. Point your webserver to the `webroot` directory.
3. Set the permissions on the `cache` directory to allow the webserver to create files. If you're lazy, `0777` will work.

    The following command changes the permissions for the `cache` directory:

    ```
    chmod -R 0777 cache
    ```
4. Start a MongoDB instance. XHGui uses the MongoDB instance to store profiling data.
5. If your MongoDB setup uses authentication, or isn't running on the default port and localhost, update XHGui's `config/config.php` so that XHGui can connect to your `mongod` instance.
6. (**Optional**, but recommended) Add indexes to MongoDB to improve performance.

    XHGui stores profiling information in a `results` collection in the `xhprof` database in MongoDB. Adding indexes improves performance, letting you navigate pages more quickly.

    To add an index, open a `mongo` shell from your command prompt. Then, use MongoDB's `db.collection.ensureIndex()` method to add the indexes, as in the following:

    ```
    $ mongo
    > use xhprof
    > db.results.ensureIndex( { 'meta.SERVER.REQUEST_TIME' : -1 } )
    > db.results.ensureIndex( { 'profile.main().wt' : -1 } )
    > db.results.ensureIndex( { 'profile.main().mu' : -1 } )
    > db.results.ensureIndex( { 'profile.main().cpu' : -1 } )
    > db.results.ensureIndex( { 'meta.url' : 1 } )
    > db.results.ensureIndex( { 'meta.simple_url' : 1 } )

    ```
7. Run XHGui's install script. The install script downloads composer and uses it to install the XHGui's dependencies.

    ```
    cd path/to/xhgui
    php install.php
    ```
8. Set up your webserver. The Configuration section below describes how to setup the rewrite rules for both nginx and apache.

Installation with Docker
========================

[](#installation-with-docker)

This setup uses [docker-compose](https://docs.docker.com/compose/) to orchestrate docker containers.

1. Clone or download `xhgui` from GitHub.
2. Startup the containers: `docker-compose up -d`
3. Open your browser at  or just
4. To customize xhgui, copy `config/config.default.php` to `config/config.php` and edit that file.
5. To customize docker-compose, copy `docker-compose.yml` to `docker-compose.override.yml` and edit that file.

Configuration
=============

[](#configuration)

Configure Webserver Re-Write Rules
----------------------------------

[](#configure-webserver-re-write-rules)

XHGui prefers to have URL rewriting enabled, but will work without it. For Apache, you can do the following to enable URL rewriting:

1. Make sure that an .htaccess override is allowed and that AllowOverride has the directive FileInfo set for the correct DocumentRoot.

    Example configuration for Apache 2.4:

    ```

        Options Indexes FollowSymLinks
        AllowOverride FileInfo
        Require all granted

    ```
2. Make sure you are loading up mod\_rewrite correctly. You should see something like:

    ```
    LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    ```
3. XHGui comes with a `.htaccess` file to enable the remaining rewrite rules.

For nginx and fast-cgi, you can use the following snippet as a start:

```
server {
    listen   80;
    server_name example.com;

    # root directive should be global
    root   /var/www/example.com/public/xhgui/webroot/;
    index  index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
```

Configure XHGui Profiling Rate
------------------------------

[](#configure-xhgui-profiling-rate)

After installing XHGui, you may want to change how frequently you profile the host application. The `profiler.enable` configuration option allows you to provide a callback function that specifies the requests that are profiled. By default, XHGui profiles 1 in 100 requests.

The following example configures XHGui to only profile requests from a specific URL path:

The following example configures XHGui to profile 1 in 100 requests, excluding requests with the `/blog` URL path:

```
// In config/config.php
return array(
    // Other config
    'profiler.enable' => function() {
        $url = $_SERVER['REQUEST_URI'];
        if (strpos($url, '/blog') === 0) {
            return false;
        }
        return rand(1, 100) === 42;
    }
);
```

In contrast, the following example configured XHGui to profile *every*request:

```
// In config/config.php
return array(
    // Other config
    'profiler.enable' => function() {
        return true;
    }
);
```

Configure 'Simple' URLs Creation
--------------------------------

[](#configure-simple-urls-creation)

XHGui generates 'simple' URLs for each profile collected. These URLs are used to generate the aggregate data used on the URL view. Since different applications have different requirements for how URLs map to logical blocks of code, the `profile.simple_url` configuration option allows you to provide specify the logic used to generate the simple URL. By default, all numeric values in the query string are removed.

```
// In config/config.php
return array(
    // Other config
    'profile.simple_url' => function($url) {
        // Your code goes here.
    }
);
```

The URL argument is the `REQUEST_URI` or `argv` value.

Configure ignored functions
---------------------------

[](#configure-ignored-functions)

You can use the `profiler.options` configuration value to set additional options for the profiler extension. This is useful when you want to exclude specific functions from your profiler data:

```
// In config/config.php
return array(
    //Other config
    'profiler.options' => [
        'ignored_functions' => ['call_user_func', 'call_user_func_array']
    ]
);
```

In addition, if you do not want to profile all PHP built-in functions, you can make use of the `profiler.skip_built_in` option.

Profiling a Web Request or CLI script
=====================================

[](#profiling-a-web-request-or-cli-script)

Using [xhgui-collector](https://github.com/pshentsoff/xhgui-collector) you can collect data from your web applications and CLI scripts. This data is then pushed into xhgui's database where it can be viewed with this application.

Saving &amp; Importing Profiles
-------------------------------

[](#saving--importing-profiles)

If your site cannot directly connect to your MongoDB instance, you can choose to save your data to a temporary file for a later import to XHGui's MongoDB database.

To configure XHGui to save your data to a temporary file, change the `save.handler` setting to `file` and define your file's path with `save.handler.filename`.

To import a saved file to MongoDB use XHGui's provided `external/import.php` script.

Be aware of file locking: depending on your workload, you may need to change the `save.handler.filename` file path to avoid file locking during the import.

The following demonstrate the use of `external/import.php`:

```
php external/import.php -f /path/to/file
```

**Warning**: Importing the same file twice will load twice the run datas inside MongoDB, resulting in duplicate profiles

Limiting MongoDB Disk Usage
---------------------------

[](#limiting-mongodb-disk-usage)

Disk usage can grow quickly, especially when profiling applications with large code bases or that use larger frameworks.

To keep the growth in check, configure MongoDB to automatically delete profiling documents once they have reached a certain age by creating a [TTL index](http://docs.mongodb.org/manual/core/index-ttl/).

Decide on a maximum profile document age in seconds: you may wish to choose a lower value in development (where you profile everything), than production (where you profile only a selection of documents). The following command instructs Mongo to delete documents over 5 days (432000 seconds) old.

```
$ mongo
> use xhprof
> db.results.ensureIndex( { "meta.request_ts" : 1 }, { expireAfterSeconds : 432000 } )

```

Waterfall Display
-----------------

[](#waterfall-display)

The goal of XHGui's waterfall display is to recognize that concurrent requests can affect each other. Concurrent database requests, CPU-intensive activities and even locks on session files can become relevant. With an Ajax-heavy application, understanding the page build is far more complex than a single load: hopefully the waterfall can help. Remember, if you're only profiling a sample of requests, the waterfall fills you with impolite lies.

Some Notes:

- There should probably be more indexes on MongoDB for this to be performant.
- The waterfall display introduces storage of a new `request_ts_micro` value, as second level granularity doesn't work well with waterfalls.
- The waterfall display is still very much in alpha.
- Feedback and pull requests are welcome :)

Using Tideways Extension
========================

[](#using-tideways-extension)

The XHProf PHP extension is not compatible with PHP7.0+. Instead you'll need to use the [tideways\_xhprof extension](https://github.com/tideways/php-profiler-extension).

Once installed, you can use the following configuration data:

```
[tideways_xhprof]
extension="/path/to/tideways/tideways_xhprof.so"
```

Releases / Changelog
====================

[](#releases--changelog)

See the [releases](https://github.com/preinheimer/xhgui/releases) for changelogs, and release information.

License
=======

[](#license)

Copyright (c) 2013 Mark Story &amp; Paul Reinheimer

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

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~292 days

Total

5

Last Release

2158d ago

PHP version history (2 changes)0.8.0PHP &gt;=5.3.0

0.10.0PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f2eab62b02d9bf6118235be046e58637702e036b95636cf4e636f6487091bc2?d=identicon)[Vadim Pshentsov](/maintainers/Vadim%20Pshentsov)

---

Top Contributors

[![markstory](https://avatars.githubusercontent.com/u/24086?v=4)](https://github.com/markstory "markstory (664 commits)")[![preinheimer](https://avatars.githubusercontent.com/u/244891?v=4)](https://github.com/preinheimer "preinheimer (58 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (17 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (17 commits)")[![Mte90](https://avatars.githubusercontent.com/u/403283?v=4)](https://github.com/Mte90 "Mte90 (12 commits)")[![bertrandmalet](https://avatars.githubusercontent.com/u/496453?v=4)](https://github.com/bertrandmalet "bertrandmalet (12 commits)")[![dumityty](https://avatars.githubusercontent.com/u/1616746?v=4)](https://github.com/dumityty "dumityty (11 commits)")[![1ma](https://avatars.githubusercontent.com/u/1456708?v=4)](https://github.com/1ma "1ma (8 commits)")[![sebbrandt87](https://avatars.githubusercontent.com/u/793580?v=4)](https://github.com/sebbrandt87 "sebbrandt87 (7 commits)")[![pshentsoff](https://avatars.githubusercontent.com/u/1342513?v=4)](https://github.com/pshentsoff "pshentsoff (6 commits)")[![beberlei](https://avatars.githubusercontent.com/u/26936?v=4)](https://github.com/beberlei "beberlei (5 commits)")[![thbourlove](https://avatars.githubusercontent.com/u/1768066?v=4)](https://github.com/thbourlove "thbourlove (5 commits)")[![lornajane](https://avatars.githubusercontent.com/u/172607?v=4)](https://github.com/lornajane "lornajane (4 commits)")[![dshafik](https://avatars.githubusercontent.com/u/58074?v=4)](https://github.com/dshafik "dshafik (3 commits)")[![david-garcia-garcia](https://avatars.githubusercontent.com/u/9599352?v=4)](https://github.com/david-garcia-garcia "david-garcia-garcia (3 commits)")[![anho](https://avatars.githubusercontent.com/u/863612?v=4)](https://github.com/anho "anho (3 commits)")[![ossinkine](https://avatars.githubusercontent.com/u/2588533?v=4)](https://github.com/ossinkine "ossinkine (2 commits)")[![kornrunner](https://avatars.githubusercontent.com/u/725986?v=4)](https://github.com/kornrunner "kornrunner (2 commits)")[![sylus](https://avatars.githubusercontent.com/u/984304?v=4)](https://github.com/sylus "sylus (2 commits)")[![skors](https://avatars.githubusercontent.com/u/2559733?v=4)](https://github.com/skors "skors (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pshentsoff-xhgui/health.svg)

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

###  Alternatives

[rarst/laps

Light WordPress profiler.

567262.1k2](/packages/rarst-laps)[rarst/wps

WordPress plugin for whoops error handler.

129133.2k3](/packages/rarst-wps)[laynefyc/xhgui-chinese

From perftools/xhgui,A web based interface for viewing profile data collected by XHProf.

8931.9k](/packages/laynefyc-xhgui-chinese)[oat-sa/tao-core

TAO core extension

66136.7k74](/packages/oat-sa-tao-core)[matthimatiker/opcache-bundle

Displays the state of the PHP opcache in the Symfony profiler toolbar.

2288.2k](/packages/matthimatiker-opcache-bundle)[yusukezzz/slim-debugbar

4213.5k](/packages/yusukezzz-slim-debugbar)

PHPackages © 2026

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