PHPackages                             ivoinov/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. [Database &amp; ORM](/categories/database)
4. /
5. ivoinov/xhgui

ActiveProject[Database &amp; ORM](/categories/database)

ivoinov/xhgui
=============

A web based interface for viewing profile data collected by XHProf

1.0.0(3mo ago)00MITJavaScriptPHP ^8.1

Since Apr 4Pushed 3mo agoCompare

[ Source](https://github.com/ivoinov/xhgui)[ Packagist](https://packagist.org/packages/ivoinov/xhgui)[ Docs](https://github.com/ivoinov/xhgui)[ RSS](/packages/ivoinov-xhgui/feed)WikiDiscussions master Synced 1mo ago

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

XHGui
=====

[](#xhgui)

A graphical interface for XHProf profiling data that can store the results in MongoDB or PDO database. Application is profiled and the profiling data is transferred to XHGui, which takes that information, saves it in MongoDB (or PDO database), and provides a convenient GUI for working with it. This project is the GUI for showing profiling results. To profile your application, use the specific minimal library:

- [perftools/php-profiler](#profiling-a-web-request-or-cli-script)[![Build Status](https://camo.githubusercontent.com/6fbab3c65b05262b3755e7cfbb76a6ed0444dcdf28280589e053e9b7adddbac3/68747470733a2f2f7472617669732d63692e6f72672f70657266746f6f6c732f78686775692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/perftools/xhgui)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c3db632f29fc67713d92af39e92d10a32ee30d79b7d07ea6cc27f7dbcda376c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70657266746f6f6c732f78686775692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/perftools/xhgui/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f3945a36bffcd46cb8519cb39c246218fc763dbd559492ad364e3587d1217a9a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70657266746f6f6c732f78686775692f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/perftools/xhgui/?branch=master)

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

[](#system-requirements)

XHGui has the following requirements:

- **PHP 8.1 or later** (PHP 8.1, 8.2, 8.3 are supported)
- If using MongoDB storage, see [MongoDB](#mongodb) requirements
- If using PDO storage, see [PDO](#pdo) requirements
- To profile an application, one of the profiling PHP extensions is required. See [Profiling a Web Request or CLI script](#profiling-a-web-request-or-cli-script). The extension is not needed to run XHGui itself. If you need to decide which backend to use, you can check the [compatibility matrix](#compatibility-matrix) to see what features are implemented or missing per backend.

MongoDB
-------

[](#mongodb)

The default installation uses MongoDB database. Most of the documentation speaks about MongoDB.

- **\[MongoDB Extension\]\[ext-mongodb\]** (ext-mongodb) version **2.0 or later**: `pecl install mongodb`
- **\[mongodb/mongodb\]\[mongodb-library\]** PHP library version **2.1 or later** (installed via Composer)
- **\[MongoDB Server\]\[mongodb\]** version **3.2 or later**\[ext-mongodb\]: \[mongodb-library\]: \[mongodb\]:

PDO
---

[](#pdo)

- \[PDO\]\[ext-pdo\] PHP extension Any of the drivers and an accompanying database:
- \[SQLite (PDO)\]\[ext-pdo\_sqlite\]
- \[MySQL (PDO)\]\[ext-pdo\_mysql\]
- \[PostgreSQL (PDO)\]\[ext-pdo\_pgsql\] NOTE: PDO may not support all the features of XHGui, see \[#320\]. \[ext-pdo\]: \[ext-pdo\_sqlite\]: \[ext-pdo\_mysql\]: \[ext-pdo\_pgsql\]: \[#320\]: [perftools#320](https://github.com/perftools/xhgui/issues/320)

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

[](#installation-from-source)

Prerequisites
-------------

[](#prerequisites)

1. **Install PHP 8.1 or later** with required extensions: ```
    # On Ubuntu/Debian
    sudo apt-get install php8.1 php8.1-cli php8.1-mongodb php8.1-json php8.1-mbstring
    # Or install ext-mongodb via PECL
    sudo pecl install mongodb
    ```
2. **Install MongoDB Server** (version 3.2 or later): ```
    # On Ubuntu/Debian - install MongoDB 6.0 or later
    # Follow official guide: https://www.mongodb.com/docs/manual/installation/
    # Start MongoDB service
    sudo systemctl start mongod
    sudo systemctl enable mongod
    ```
3. **Install Composer** (if not already installed): ```
    curl -sS https://getcomposer.org/installer | php
    sudo mv composer.phar /usr/local/bin/composer
    ```

Installation Steps
------------------

[](#installation-steps)

1. **Clone or download `xhgui` from GitHub:**```
    git clone https://github.com/perftools/xhgui.git
    cd xhgui
    ```
2. **Install PHP dependencies with Composer:**```
    composer install --no-dev
    ```

    For development (includes testing tools): ```
    composer install
    ```
3. **Set the permissions on the `cache` directory:**```
    chmod -R 0777 cache
    ```
4. **Configure MongoDB connection** (if not using defaults): Copy the default configuration file and customize it: ```
    cp src/config.default.php config/config.php
    ```

    Edit `config/config.php` to update MongoDB connection settings if your MongoDB:
    - Uses authentication
    - Runs on a non-default port
    - Runs on a different hostname
5. **Create MongoDB indexes** (recommended for performance): XHGui stores profiling information in a `results` collection in the `xhgui` database. Adding indexes improves query performance. Connect to MongoDB and create indexes: ```
    mongosh
    ```

    Then in the MongoDB shell: ```
    use xhgui
    db.results.createIndex({ 'meta.SERVER.REQUEST_TIME': -1 })
    db.results.createIndex({ 'profile.main().wt': -1 })
    db.results.createIndex({ 'profile.main().mu': -1 })
    db.results.createIndex({ 'profile.main().cpu': -1 })
    db.results.createIndex({ 'meta.url': 1 })
    db.results.createIndex({ 'meta.simple_url': 1 })
    db.results.createIndex({ 'meta.SERVER.SERVER_NAME': 1 })
    db.results.createIndex({ 'meta.request_ts': 1 })
    ```
6. **Point your webserver to the `webroot` directory.**See the [Configuration section](#configuration) below for webserver setup examples.

Verify Installation
-------------------

[](#verify-installation)

Run the test suite to verify everything is working:

```
composer test
```

All tests should pass (some may be marked as incomplete or skipped depending on your setup).

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

[](#installation-with-docker)

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

- PHP 8.1+ with ext-mongodb 2.x
- MongoDB 6.0+
- Nginx web server

Quick Start
-----------

[](#quick-start)

1. **Copy example [`docker-compose.yml`](https://github.com/perftools/xhgui/raw/HEAD/docker-compose.yml) from this project**
2. **Startup the containers:**```
    docker-compose up -d
    ```
3. **Access the application:**
    - Open your browser at
    - Or just
    - Or type at terminal: `composer openurl`
4. **Customize configuration (optional):**Copy [`src/config.default.php`](https://github.com/perftools/xhgui/raw/HEAD/src/config.default.php) to `config/config.php` and edit that file. ```
    cp src/config.default.php config/config.php
    ```

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;
    }
}
```

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

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

The supported way to profile an application is to use [perftools/php-profiler](https://github.com/perftools/php-profiler)package. You can use that package to collect data from your web application or a CLI script. This data is then pushed into XHGui database where it can be viewed with XHGui application. The `php-profiler` package offers submitting data directly to XHGui instance once the profiling is complete at the end of the request. If the application cannot directly connect to XHGui instance, the package offers solution to capture profiling data to a file which you can import later using the [import](https://github.com/perftools/php-profiler#import-jsonl-files) script. **Warning**: Importing the same file twice will create duplicate profiles.

Importing Profiling Data
------------------------

[](#importing-profiling-data)

If your application cannot directly connect to XHGui, you can capture profiling data to files and import them later.

### CLI Import (Recommended)

[](#cli-import-recommended)

Use the command-line import script for batch imports:

```
php external/import.php -f /path/to/profiles.jsonl
```

**Note**: `import.php` is a CLI-only script. Do NOT include it in your web server configuration.

### Web-Based Import

[](#web-based-import)

For importing via HTTP, use the web endpoint:

```
# Upload a file
curl -X POST -F "file=@profiles.jsonl" http://your-xhgui-server/external/web-import.php

# Or send raw data
curl -X POST --data-binary @profiles.jsonl http://your-xhgui-server/external/web-import.php
```

⚠️ **Security**: The web import endpoint should be protected with authentication or IP restrictions. See `external/README.md` for security configuration examples.

**Warning**: Importing the same file multiple times will create duplicate profiles.

For more details, see [external/README.md](external/README.md).

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 MongoDB to delete documents over 5 days (432000 seconds) old.

```
mongosh
```

Then in the MongoDB shell:

```
use xhgui
db.results.createIndex({ "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 :)

Development
===========

[](#development)

Running Tests
-------------

[](#running-tests)

XHGui includes a comprehensive test suite. To run the tests:

```
# Install development dependencies (if not already installed)
composer install
# Run the test suite
composer test
# Run tests with coverage
composer cover
```

Code Quality
------------

[](#code-quality)

Check code style:

```
composer check-cs
```

Fix code style automatically:

```
composer fix-cs
```

Requirements for Development
----------------------------

[](#requirements-for-development)

- PHP 8.1 or later
- ext-mongodb 2.0 or later
- MongoDB Server 3.2 or later (for integration tests)
- Composer

Monitoring
==========

[](#monitoring)

[Prometheus](https://prometheus.io) metrics suitable for monitoring service health are exposed on `/metrics`. (This currently only works if using PDO for storage.)

Compatibility matrix
====================

[](#compatibility-matrix)

FeatureMongoDBPDOPrometheus exporter✗✓ \[#305\]Searcher::latest()✓✓Searcher::query()✓✗ \[#384\]Searcher::get()✓✓Searcher::getForUrl()✓✓ \[#436\]Searcher::getPercentileForUrl()✓✓ \[#436\]Searcher::getAvgsForUrl()✓✗ \[#384\]Searcher::getAll(sort)✓✓ \[#436\]Searcher::getAll(direction)✓✓ \[#436\]Searcher::delete()✓✓Searcher::truncate()✓✓Searcher::saveWatch()✓✓ \[#435\]Searcher::getAllWatches()✓✓ \[#435\]Searcher::truncateWatches()✓✓ \[#435\]Searcher::stats()✗ \[#305\]✓Searcher::getAllServerNames()✓ \[#460\]✗\[#305\]: [perftools#305](https://github.com/perftools/xhgui/pull/305)\[#384\]: [perftools#384](https://github.com/perftools/xhgui/pull/384)\[#435\]: [perftools#435](https://github.com/perftools/xhgui/pull/435)\[#436\]: [perftools#436](https://github.com/perftools/xhgui/pull/436)\[#460\]: [perftools#460](https://github.com/perftools/xhgui/pull/460)Releases / Changelog
====================

[](#releases--changelog)

See the [releases](https://github.com/perftools/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

49

—

FairBetter than 95% of packages

Maintenance81

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~52 days

Total

49

Last Release

99d ago

Major Versions

0.24.x-dev → 1.0.02026-02-02

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

0.10.0PHP ^5.6 || ^7.0

0.13.0PHP ^7.0

0.18.0PHP ^7.2 || ^8.0

0.20.1PHP ^7.2 || ~8.0 || ~8.1

0.23.2PHP ^8.0

0.24.x-devPHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/25d12398c6739d7a9cdbd60381fd42716e6af3be2a58da9ce353741a0540894f?d=identicon)[ivoinov](/maintainers/ivoinov)

---

Top Contributors

[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (721 commits)")[![markstory](https://avatars.githubusercontent.com/u/24086?v=4)](https://github.com/markstory "markstory (682 commits)")[![preinheimer](https://avatars.githubusercontent.com/u/244891?v=4)](https://github.com/preinheimer "preinheimer (58 commits)")[![1ma](https://avatars.githubusercontent.com/u/1456708?v=4)](https://github.com/1ma "1ma (25 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (19 commits)")[![Mte90](https://avatars.githubusercontent.com/u/403283?v=4)](https://github.com/Mte90 "Mte90 (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 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)")[![sebbrandt87](https://avatars.githubusercontent.com/u/793580?v=4)](https://github.com/sebbrandt87 "sebbrandt87 (7 commits)")[![PierrePaul](https://avatars.githubusercontent.com/u/149291?v=4)](https://github.com/PierrePaul "PierrePaul (5 commits)")[![beberlei](https://avatars.githubusercontent.com/u/26936?v=4)](https://github.com/beberlei "beberlei (5 commits)")[![illia-voinov](https://avatars.githubusercontent.com/u/144820647?v=4)](https://github.com/illia-voinov "illia-voinov (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)")[![lauripiisang](https://avatars.githubusercontent.com/u/5603529?v=4)](https://github.com/lauripiisang "lauripiisang (3 commits)")[![anho](https://avatars.githubusercontent.com/u/863612?v=4)](https://github.com/anho "anho (3 commits)")[![david-garcia-garcia](https://avatars.githubusercontent.com/u/9599352?v=4)](https://github.com/david-garcia-garcia "david-garcia-garcia (3 commits)")[![dshafik](https://avatars.githubusercontent.com/u/58074?v=4)](https://github.com/dshafik "dshafik (3 commits)")[![kornrunner](https://avatars.githubusercontent.com/u/725986?v=4)](https://github.com/kornrunner "kornrunner (3 commits)")

---

Tags

performanceprofilingmongodbxhprofxhgui

### Embed Badge

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

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k23.3M302](/packages/doctrine-mongodb-odm)[doctrine/mongodb-odm-bundle

Symfony Doctrine MongoDB Bundle

38418.7M195](/packages/doctrine-mongodb-odm-bundle)[alcaeus/mongo-php-adapter

Adapter to provide ext-mongo interface on top of mongo-php-library

46412.3M73](/packages/alcaeus-mongo-php-adapter)[omines/datatables-bundle

Symfony DataTables Bundle with native Doctrine ORM, Elastica and MongoDB support

2851.4M6](/packages/omines-datatables-bundle)

PHPackages © 2026

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