Running XHProf with Graphviz in a Docker Container for PHP Profiling
This article explains how to use a pre‑built Docker image that bundles XHProf and Graphviz to generate and view PHP profiling reports without manual installation of dependencies, providing step‑by‑step commands for pulling the image, running the container, copying data, and accessing the visual report in a browser.
XHProf is a PHP profiling tool that typically requires Nginx and Graphviz to render its analysis results, which can be cumbersome to set up on Windows or macOS when only a single report is needed.
To simplify the process, the author created a Docker image that already includes XHProf, Nginx, and Graphviz, allowing users to start the container and drop the profiling data files into it for immediate visualization.
Pull the Docker image:
docker pull 1000172/xhprof_graphviz:v1Run the container, optionally mapping a host port to the container’s web server (e.g., host port 8888 to container port 80):
docker run --name tn -p 8888:80 -d 1000172/xhprof_graphviz:v1Copy the generated XHProf data files into the container’s designated directory (e.g., /usr/share/nginx/data ) using docker cp :
docker cp 5fd9708466af4.api_demo.xhprof tn:/usr/share/nginx/dataAfter copying, open a web browser and navigate to http://localhost:8888/xhprof_html/ to view the profiling report; the embedded Graphviz tools render the call‑graph diagrams automatically.
The author invites readers to suggest additional analysis tools to be packaged into the image and promises to test and share updates.
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.