Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk12 min

How to Set Up XHProf and XHGui for Profiling PHP Applications

A complete setup guide for profiling PHP applications with a compatible XHProf extension, perftools/php-profiler, and XHGui backed by MongoDB or PDO.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the profiler extension that matches your PHP runtime, add perftools/php-profiler to the application, and send selected request traces to an XHGui installation backed by MongoDB or PDO. XHProf records function-level call timing and memory data; XHGui stores those runs and provides the web interface for comparing them. The reliable setup order is extension, Composer integration, early bootstrap instrumentation, saver configuration, XHGui deployment, database configuration, and a test request.

What XHProf and XHGui do

XHProf is a function-level hierarchical profiler for PHP with a simple HTML interface. In a running request, it records a call hierarchy rather than only a total response time. That hierarchy lets you see which functions called one another, how often they ran, how much time they consumed, and how memory changed while they executed.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

XHGui is the separate graphical interface and persistence layer. The profiled application sends a run to XHGui, which stores profile documents in MongoDB or through a PDO-backed database and renders lists, details, metrics, and call graphs. XHGui does not provide the profiling extension itself; the PHP runtime executing your application must load one.

A useful mental model is:

  • Profiler extension: collects low-level function data inside PHP.
  • perftools/php-profiler: starts and stops profiling from application code and sends the result through a saver.
  • XHGui: receives, stores, indexes, and displays the saved run.

The project description is precise: “XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface.”

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Check PHP and profiler compatibility first

Choose the extension before installing anything else. The maintained XHGui repository lists PHP 8.0 through 8.3 as known to work. XHGui itself does not require a profiling extension, but every application request you want to profile does.

PHP runtime Profiler options documented by the integration library Installation path
PHP 7 or later Tideways XHProf 5.x, XHProf 2.x, or Tideways 4.x pecl install xhprof for the documented XHProf path
PHP 5.3 through below PHP 7 XHProf 0.9.x or UProfiler pecl install xhprof-0.9.4 for the documented older XHProf path

The version ranges above come from the perftools/php-profiler compatibility documentation. Do not install the PHP 5 extension into a PHP 7 or newer runtime, or assume that an extension loaded by the command-line interpreter is also loaded by PHP-FPM or Apache. Those processes can use different binaries and configuration files.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare the application and XHGui host

Before changing code, identify these details:

  • The PHP binary and minor version used by the web worker that serves the application.
  • Whether the application runs under Apache, nginx with PHP-FPM, or another front end.
  • Which requests should be profiled, such as a representative page render, API endpoint, queue job entry point, or CLI command.
  • Whether profile documents will be stored in MongoDB, PDO, files for later upload, or directly submitted to XHGui.
  • Where the XHGui source will live and which account needs write access to its cache directory.

Profiling every request indefinitely can create a large data set and make analysis harder. Start with a small, representative set of requests and add broader collection only when you have a retention and storage plan.

Install and verify the profiler extension

Install the extension for the selected PHP version

For a PHP 7 or newer environment following the documented XHProf path, run:

pecl install xhprof

For an older PHP 5 environment using the documented XHProf 0.9.4 release, run:

pecl install xhprof-0.9.4

Tideways XHProf is another supported PHP 7 or newer option. Whichever extension you choose, enable it in the configuration file used by the actual web worker, then restart PHP-FPM, Apache, or the relevant worker service. Restarting only a shell session does not reload an already-running worker.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify the loaded module in each execution context

Check the command-line environment with:

php -m

Look for the installed profiler module. Then verify the web environment separately, for example with the runtime information page or your process manager’s diagnostic output. If CLI reports the module but a web request does not, compare the PHP executable, php.ini path, additional scan directory, and service restart status. The integration library can only detect a profiler that is loaded in the process running the application.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Add the Composer integration library

From the application directory, install the integration package:

composer require perftools/php-profiler

The package detects supported profiler extensions and can be configured to select one explicitly when more than one is present. Keep the package in the same dependency set as the application code so deployments use a reproducible version.

Start profiling from an early bootstrap point

Instrumentation belongs in a central bootstrap path that runs before the work you want to measure. Depending on the framework, that may be the front controller, application kernel bootstrap, console entry point, or a shared worker initialization file. Starting too late omits framework startup and dependency construction; placing the code in only one controller misses other routes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The documented pattern creates a configuration object, constructs XhguiProfilerProfiler, and calls start(). A minimal bootstrap shape is:

<?php

require __DIR__ . '/vendor/autoload.php';

$config = require __DIR__ . '/config/profiler.php';
$profiler = new XhguiProfilerProfiler($config);
$profiler->start();

Use the configuration format shipped with the version of perftools/php-profiler you installed. The important operational points are that the code executes early, the selected extension is available, and shutdown handling is allowed to flush the run when the request ends. Do not instantiate a second profiler in every controller or middleware layer.

For command-line programs, put the same startup call in the command entry point and pass a request context that identifies the command and its arguments without exposing secrets. For web requests, preserve the URL, host, and route context that will help you identify the run later in XHGui.

Choose how profile data is saved

The integration library supports several saver strategies. The right choice depends on whether the application can reach XHGui directly and whether you need a buffer between collection and analysis.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
Workflow When it fits Trade-off
Direct upload to XHGui The profiled application can reach the XHGui endpoint and you want runs available immediately. Couples request completion to the upload path and requires dependable connectivity.
JSON Lines output You want to write runs locally or to a durable spool and import them later. Requires file permissions, rotation, and an import process; files can grow quickly.
File or stack saver You need buffering or a deployment where the application should not connect directly to the database. Adds an operational step between collection and viewing.
MongoDB or PDO saver You have a database connection available to the application. The integration documentation discourages direct MongoDB/PDO saving in favor of upload, file, or stack savers where appropriate.

Configure one saver in the profiler configuration and confirm that it can write before enabling a large sampling scope. If a request completes but no run appears, the saver, endpoint, database connection, and filesystem permissions are the first places to inspect.

Deploy XHGui from source

Install the application

Clone or download the XHGui repository on the host that will serve the interface. From its directory, install production dependencies with:

composer install --no-dev

Point the web server’s document root at XHGui’s webroot directory, not the repository root. Make the repository’s cache directory writable by the account used by the web server. A read-only cache commonly results in an empty interface or runtime errors even when the database is reachable.

Set the XHGui configuration

The default installation uses MongoDB. If MongoDB is not available at the default local connection, update config/config.php with the correct host, port, credentials, and database settings for your environment. Keep those credentials outside publicly served files and grant only the permissions XHGui needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a customized installation, the repository provides src/config.default.php. Copy it to config/config.php, then adjust the storage and application settings rather than editing the default source file.

Configure MongoDB or PDO storage

MongoDB: the complete-feature path

The documented MongoDB path requires MongoDB PHP driver 1.3.0 or later and MongoDB server 3.2 or later. Confirm both the PHP driver loaded by the XHGui web process and the server version before troubleshooting the application integration.

MongoDB is the default XHGui storage choice and is the safest option when you need the feature set documented by the project. After initial data arrives, add the indexes documented by XHGui for request time, URL, server name, and profile metrics. Those indexes support the filters and sorting used by the interface and help prevent slow queries as the collection grows.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

PDO: relational alternatives with limitations

PDO storage can use SQLite, MySQL, or PostgreSQL. The XHGui documentation warns that PDO may not support every XHGui feature, so choose it when your environment requires a relational database and you accept that reduced coverage. Validate the views and filters you depend on with a real captured run rather than assuming parity with MongoDB.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure Apache or nginx

Apache requirements

XHGui includes an .htaccess file. Apache must allow the relevant override rules, including AllowOverride FileInfo, and mod_rewrite must be enabled. If the home page loads but detail URLs return 404, inspect the virtual host’s override policy and rewrite module before changing application code.

nginx with PHP-FPM

Serve the webroot directory and route paths that do not map to a real file to index.php. The PHP location must set SCRIPT_FILENAME to the document root plus the requested script. A conventional shape is:

root /var/www/xhgui/webroot;

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

location ~ .php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php-fpm.sock;
}

Use the PHP-FPM socket or upstream name provided by your installation. After reloading nginx and PHP-FPM, open the XHGui URL directly and verify that the front page and a detail route both resolve.

Use Docker Compose instead of a source deployment

The XHGui repository documents a Docker Compose route for a quicker local or disposable setup:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Copy the example docker-compose.yml into your working directory.
  2. Start the services with docker-compose up -d.
  3. Open the local XHGui URL exposed by the Compose configuration.
  4. If customization is needed, copy src/config.default.php to config/config.php and edit the copied file.

Use the same application-side profiler configuration regardless of whether XHGui runs from source or in containers. The difference is operational: Docker packages the web and database services, while a source deployment leaves service installation, upgrades, permissions, and process supervision to you.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Capture and confirm the first run

  1. Open the XHGui URL and leave it available for comparison.
  2. Exercise one representative application request, such as a page that performs the database and template work you need to understand.
  3. Include a useful request context. A URL, route name, or CLI command makes the saved metadata identifiable.
  4. Wait for the request to finish so shutdown handling can flush the profile.
  5. Refresh XHGui and locate the new run by request time, URL, server name, or other displayed context.
  6. Open the run detail and confirm that function calls, timing, call counts, memory, and the call graph contain data rather than an empty document.

If the run is present, repeat the same request several times before drawing conclusions. One trace can include cache warm-up, connection setup, or an unusual input. Use comparable requests when evaluating a code change.

Read a profile without misdiagnosing it

Inclusive versus exclusive time

Inclusive time attributes a function’s own work plus the work performed by functions it called. It helps identify an expensive subtree. Exclusive time removes child calls and shows work performed in that function itself. A controller with high inclusive time may simply be the entry point for a slow database or template operation; inspect its children before rewriting the controller.

Call counts and memory

A high call count can indicate a loop, repeated service lookup, or an unexpectedly chatty abstraction. Pair the count with inclusive and exclusive time: many cheap calls are a different problem from a few very expensive calls. Memory measurements help identify allocations and retained structures, but interpret them alongside the request path and input size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The call graph

Follow the graph from the request entry point toward the largest inclusive-time branches. Confirm that the branch is present in representative requests, then investigate the responsible SQL, cache, serialization, template, or application function outside the profiler. XHProf identifies where execution time accumulates; it does not by itself explain whether a query plan, network dependency, or algorithm is the root cause.

Reduce noise and control collection

The profiler library supports ignored functions through profiler.options. Use that option when framework internals or known utility calls overwhelm the functions you are trying to study. The library also exposes profiling flags that can disable built-in-function profiling when the default trace is too broad. Apply these settings deliberately: removing too much detail can hide the call that explains a delay.

Prefer selective sampling over always-on collection for a busy production system. Profile a controlled percentage of requests, a specific route, a maintenance window, or a reproducer. Keep an unsampled baseline for comparison, and record which sampling rule was active so runs from different collection policies are not treated as equivalent.

Retention, indexes, and storage growth

Profile documents can consume storage quickly, especially when they include large call trees and many requests. Decide how long a run remains useful before enabling broad collection. XHGui recommends controlling profile age; with MongoDB, a TTL index can remove documents after the chosen age.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Set a maximum profile age that matches the investigation cycle.
  • Use the documented indexes for request time, URL, server name, and profile metrics.
  • Monitor the database or JSON Lines directory rather than waiting for the disk to fill.
  • Rotate or archive file-based output when using a file or stack saver.
  • Remove test data before production collection if it could confuse comparisons.

Troubleshoot common failures

The profiler is not detected

  • Run php -m and verify the module in the same PHP installation used by the application.
  • Check the PHP-FPM or Apache module configuration separately from CLI configuration.
  • Confirm the extension version matches the PHP major version and restart the worker after enabling it.
  • Verify that only a supported profiler is selected when multiple extensions are installed.

XHGui shows no runs

  • Confirm that the bootstrap path executes before the request work begins.
  • Inspect saver configuration and application logs for upload or serialization errors.
  • Test the MongoDB or PDO connection from the process that writes the run.
  • Check write permissions for XHGui’s cache directory and any JSON Lines output directory.
  • Ensure shutdown handling is not being terminated before the profile is flushed.

Routes return 404

  • With Apache, verify mod_rewrite and the AllowOverride FileInfo setting.
  • With nginx, confirm that unknown paths fall through to /index.php.
  • Check that the document root is XHGui’s webroot, not its parent directory.

MongoDB queries become slow

Add the XHGui-documented indexes for request time, URL, server name, and profile metrics. Then review retention; an unbounded collection can make otherwise correct queries progressively more expensive.

Storage grows without bound

Reduce the sampling scope, configure a maximum profile age, enable a MongoDB TTL index where appropriate, and rotate file-based output. Deleting old runs is a storage policy decision, so set it before enabling continuous collection.

Choose an implementation path

Decision Prefer this when Important limitation
MongoDB over PDO You want the default XHGui path and the broadest documented feature coverage. Requires the MongoDB PHP driver 1.3.0 or later and MongoDB server 3.2 or later.
PDO over MongoDB Your infrastructure standardizes on SQLite, MySQL, or PostgreSQL. The documentation warns that some XHGui features may be unavailable.
Source deployment over Docker You need direct control over the web server, PHP process, filesystem, and upgrade process. You must manage those services and permissions yourself.
Docker Compose over source You need a repeatable local or disposable environment with fewer manual service steps. Container networking, volumes, and exposed ports still need to be maintained.
Direct submission over file/import The application can reliably reach XHGui and you need runs immediately. A failed or slow destination can affect the submission path.
File or stack saver over direct submission You want buffering, delayed import, or isolation between the application and XHGui. You must operate the spool, permissions, rotation, and import flow.
Selective sampling over always-on collection You are profiling a busy or sensitive environment. You may miss rare requests unless the sampling rule targets them.

Operational checklist

  • PHP 8.0–8.3 is within the maintained XHGui repository’s known-working range.
  • The profiler extension matches the PHP runtime and is loaded by the web worker.
  • perftools/php-profiler is installed through Composer.
  • The profiler starts from an early, central bootstrap path.
  • A saver is configured and can write or upload a test run.
  • XHGui is served from webroot and its cache directory is writable.
  • MongoDB or PDO storage is configured and reachable.
  • Apache rewrites or nginx front-controller routing are working.
  • A representative request produces a visible run with timing and call data.
  • Retention, indexes, and sampling prevent uncontrolled growth.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.