XHgui
A Docker image that includes the XHGui web interface, which can be used in conjunction with Xhprof to view PHP profiling data.
Setup
Install dependencies
composer require --dev perftools/php-profiler
Bootstrap code
bootstrap.php$profiler = new \Xhgui\Profiler\Profiler(['save.handler' => \Xhgui\Profiler\Profiler::SAVER_FILE,'save.handler.file' => ['filename' => '/mnt/files/xhprof/xhgui.data.jsonl',],]);$profiler->start();
(*) Update configuration
If your application makes use of services that run on localhost you should adjust your configuration to use an alternative DNS name:
- localhost:3306+ host.docker.internal:3306
Create Docker setup
docker-compose-xhgui.ymlversion: "3.8"services:nginx-xhprof:image: wodby/nginx:1.19environment:NGINX_VHOST_PRESET: phpNGINX_BACKEND_HOST: xhprofNGINX_SERVER_ROOT: /var/www/html/public
Usage
Step 1.
Start the containers:
docker compose -f docker-compose.yml -f docker-compose-xhgui.yml up -d
Step 2.
Navigate to your page on localhost:8000 to capture the profiling data.
Step 3.
Execute the following command to load the data into XHGui:
docker compose -f docker-compose-xhgui.yml exec xhgui php /var/www/xhgui/external/import.php -f /data/xhprof/xhgui.data.jsonl
Step 4.
Find XHGui on localhost:8001.