Go to the Dockerfile.dev
and add lines:
# Install XHProf
RUN cd /root && \
curl "https://github.com/tideways/php-xhprof-extension/archive/v5.0.0.tar.gz" -fsL -o ./a.tar.gz && \
tar xf ./a.tar.gz && \
cd ./php-xhprof-extension-5.0.0 && \
phpize && \
./configure && \
make && \
make install && \
cd .. && rm -rf ./a.tar.gz ./php-xhprof-extension-5.0.0 && \
docker-php-ext-enable tideways_xhprof && \
cd /srv/www/service/
Go to the public/index.php
and add lines:
<?php
// after use (...) block:
// xhprof: init
tideways_xhprof_enable();
// ... all requires and calls goes there...
// xhprof: save data
$run = uniqid();
$type = "service-name";
$filename = "/srv/www/service/var/profiles/$run.$type.xhprof";
file_put_contents($filename, serialize(tideways_xhprof_disable()));
Go to the docker-compose.yml
and add lines:
services:
# ...
xhprof:
image: tuimedia/xhprof-docker:0.9.4
volumes:
- ./var/profiles:/profiles
ports:
- "8081:80"
# ...