Backend Development 3 min read

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.

php中文网 Courses
php中文网 Courses
php中文网 Courses
Running XHProf with Graphviz in a Docker Container for PHP Profiling

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:v1

Run 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:v1

Copy 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/data

After 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.

backendDockerProfilingGraphvizxhprof
php中文网 Courses
Written by

php中文网 Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.