Yep – it’s necessary. I really need to dig into that page load; what’s happening in this evironment and why? It’s time to setup xdebug and webgrind.
We’ll use the Geniem Oy’s images and repo for the foundation. I’m specifically interested in the webgrind service, and will add this to my docker-compose.yml file:
webgrind:
image: devgeniem/webgrind
ports:
- 80
volumes_from:
- web
I will customize it a bit, so it fits my workflow, and I’ll make the UI available on port 8081;
webgrind:
image: devgeniem/webgrind
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.${NAME}-debug.rule=Host(`debug.schoolupdate.c7`)"
- "traefik.http.routers.${NAME}-debug.tls=true"
ports:
- 443:80
volumes:
- ./debug:/tmp/xdebug
I then need to confirm or configure my own wordpress service and make the xdebug output dir is set. My WordPress service looks like this:
wordpress:
container_name: ${NAME}-wordpress
user: "1000:1000"
build:
context: /home/mklasen/server-management/config/wordpress
dockerfile: wordpress.Dockerfile
depends_on:
- db
expose:
- "9000"
volumes:
- /home/mklasen/server-management/config/php/default.conf:/usr/local/etc/php/conf.d/php.ini
- ./:/var/www/
- ./debug:/tmp/xdebug
links:
- db
external_links:
- catchall
environment:
PHP_AUTOCONF: /usr/bin/autoconf
and the xdebug part of my php.ini (not all settings here are relevant):
xdebug.client_host = localhost
xdebug.mode = debug,develop,profile,trace
xdebug.start_with_request = yes
xdebug.client_port = 9003
xdebug.idekey=VSCODE
xdebug.cli_color=2
xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024
xdebug.output_dir=/tmp/xdebug
Alright, let’s move ahead and restart the docker compose environment with:
docker-compose stop && docker-compose up -d
Now, I did run into some issues like “NOTICE: PHP message: Xdebug: [Profiler] File ‘/tmp/xdebug/cachegrind.out.*’ could not be opened.”
This was related to the permissions the directory has. After running a chmod -R 777 debug
on my docker volume folder, this was resolved.
Now, that’s all to really start understanding what’s going on in your PHP web applications,
Happy developing!
Leave a Reply