This addon adds the XHGui service to a project served by DDEV.
XhGui is a graphical interface for XHProf profiling data that can store the results in MongoDB or PDO database.
See https://performance.wikimedia.org/xhgui/ for an demonstration of XHGui data collection.
This addon is for debugging in a development environment. Profiling in a production environment is not recommended.
-
Install the
ddev-xhgui
add-on:For DDEV v1.23.5 or above run
ddev add-on get ddev/ddev-xhgui
For earlier versions of DDEV run
ddev get ddev/ddev-xhgui
Then restart your project
ddev restart
-
Install
perftools/php-profiler
ddev composer require perftools/php-profiler --dev
-
Add the following line to
src/Application.php
to include the collector.public function bootstrap(): void { parent::bootstrap(); // Below is the new code to add if (file_exists("/mnt/ddev_config/xhgui/collector/xhgui.collector.php")) { require_once "/mnt/ddev_config/xhgui/collector/xhgui.collector.php"; }
-
Run
ddev xhprof
to start profiling.- XHGui is now available at
https://yourproject.ddev.site:8142
- XHGui is now available at
-
Install
perftools/php-profiler
ddev composer require perftools/php-profiler --dev
-
Add the following line to
web/sites/default/settings.php
to include the collector.if (file_exists("/mnt/ddev_config/xhgui/collector/xhgui.collector.php")) { require_once "/mnt/ddev_config/xhgui/collector/xhgui.collector.php"; }
-
Run
ddev xhprof
to start profiling.- XHGui is now available at
https://yourproject.ddev.site:8142
- XHGui is now available at
-
Install
perftools/php-profiler
ddev composer require perftools/php-profiler --dev
-
Add the following line to
app/Providers/AppServiceProvider.php
to include the collector.public function boot(): void { if (file_exists("/mnt/ddev_config/xhgui/collector/xhgui.collector.php")) { require_once "/mnt/ddev_config/xhgui/collector/xhgui.collector.php"; } ...
-
Run
ddev xhprof
to start profiling.- XHGui is now available at
https://yourproject.ddev.site:8142
- XHGui is now available at
-
Install
perftools/php-profiler
ddev composer require perftools/php-profiler --dev
-
Add the following line to
app/Mage.php
, right after the "AUTOLOADER PATCH", to include the collector.if (file_exists("/mnt/ddev_config/xhgui/collector/xhgui.collector.php")) { require_once "/mnt/ddev_config/xhgui/collector/xhgui.collector.php"; }
-
Run
ddev xhprof
to start profiling.- XHGui is now available at
https://yourproject.ddev.site:8142
- XHGui is now available at
-
Install
perftools/php-profiler
ddev composer require perftools/php-profiler --dev
-
Add the following line to
public/index.php
, right after the autoload includes, to include the collector.if (file_exists(__DIR__ . '/../vendor/autoload.php')) { require __DIR__ . '/../vendor/autoload.php'; } elseif (file_exists(__DIR__ . '/vendor/autoload.php')) { require __DIR__ . '/vendor/autoload.php'; } else { header('HTTP/1.1 500 Internal Server Error'); echo "autoload.php not found"; exit(1); } if (file_exists("/mnt/ddev_config/xhgui/collector/xhgui.collector.php")) { require_once "/mnt/ddev_config/xhgui/collector/xhgui.collector.php"; }
-
Run
ddev xhprof
to start profiling- XHGui is now available at
https://yourproject.ddev.site:8142
- XHGui is now available at
-
Install
perftools/php-profiler
- If using bedrock
ddev composer require perftools/php-profiler --dev
- If using vanilla WordPress:
git clone https://github.com/perftools/php-profiler.git
-
Add the following line to
wp-config-ddev.php
to include the collector.require_once __DIR__ . '/php-profiler/autoload.php'; if (file_exists("/mnt/ddev_config/xhgui/collector/xhgui.collector.php")) { require_once "/mnt/ddev_config/xhgui/collector/xhgui.collector.php"; }
-
Remove
#ddev-generated
fromwp-config-ddev.php
to prevent DDEV overriding it. -
Run
ddev xhprof
to start profiling- XHGui is now available at
https://yourproject.ddev.site:8142
- XHGui is now available at
The service will automatically start when run: ddev start
or ddev restart
.
By default, xhgui will be available at https://yourproject.ddev.site:8143
.
Use the following command to launch the xhgui in your browser:
ddev xhgui
For detailed information about a single request, click on the "Method" keyword on the "Recent runs" dashboard.
Remember, if you updated settings.ddev.php
or wp-config-ddev.php
, these file will be overwritten unless you remove the #ddev-generated
.
Use the following command to check the logs:
ddev logs -s xhgui
To configure Xhgui, update .ddev/xhgui/xhgui.config.php
.
For example, to set xhgui to use Asia/Toyko
timezone for dates:
-
Remove
#ddev-generated
from.ddev/xhgui/xhgui.config.php
-
Change the timezone value
'timezone' => 'Asia/Tokyo', 'date.format' => 'Y-m-d H:i:s',
Contributed and maintained by @tyler36 based on the original ddev-contrib PR by @penyaskito