This directory contains Docker-based test environments for verifying xdebug-mcp's container integration.
# Build the test container
docker compose build
# Verify container works
docker compose run --rm php php -v
docker compose run --rm php php -m | grep xdebug
# Run test script directly
docker compose run --rm php php /app/test_script.php# Test trace functionality
./bin/xtrace --context="Docker trace test" -- \
docker compose -f tests/docker/docker-compose.yml run --rm php php /app/test_script.php
# Test profile functionality
./bin/xprofile --context="Docker profile test" -- \
docker compose -f tests/docker/docker-compose.yml run --rm php php /app/test_performance.php
# Test coverage functionality
./bin/xcoverage -- \
docker compose -f tests/docker/docker-compose.yml run --rm php php /app/test_coverage.php# Start container in background
docker compose -f tests/docker/docker-compose.yml up -d
# Run trace
./bin/xtrace -- \
docker compose -f tests/docker/docker-compose.yml exec -T php php /app/test_script.php
# Stop container
docker compose -f tests/docker/docker-compose.yml down| Script | Purpose |
|---|---|
test_script.php |
Basic function calls, recursion, array operations |
test_coverage.php |
Code coverage testing with branches and conditionals |
test_performance.php |
Performance profiling with intentionally slow algorithms |
The XdebugRunner class handles Docker integration by:
- Detecting container commands: Recognizes
docker,podman,kubectl - Finding PHP position: Locates the
phpcommand within the Docker command - Injecting Xdebug args: Inserts
-dxdebug.*options afterphp
Input: docker compose run --rm php php /app/test.php
Output: docker compose run --rm php php -dxdebug.mode=trace -dxdebug.start_with_request=yes ... /app/test.php
Ensure /tmp is mounted in the container:
volumes:
- /tmp:/tmpCheck Xdebug is installed:
docker compose run --rm php php -m | grep xdebugThe container runs as root by default. If you need specific user permissions:
user: "${UID}:${GID}"Host Machine
├── xdebug-mcp tools (bin/x*)
├── XdebugRunner class (src/XdebugRunner.php)
│ └── Detects Docker and injects Xdebug args
└── /tmp (shared volume)
├── trace.*.xt
└── cachegrind.out.*
Docker Container
├── PHP 8.4 + Xdebug
├── /app (test scripts)
└── /tmp (mounted from host)