webgrind:\n image: devgeniem\/webgrind\n ports:\n - 80\n volumes_from:\n - web<\/code><\/pre>\n\n\n\nI will customize it a bit, so it fits my workflow, and I’ll make the UI available on port 8081;<\/p>\n\n\n\n
webgrind:\n image: devgeniem\/webgrind\n labels:\n - \"traefik.enable=true\"\n - \"traefik.docker.network=traefik_proxy\"\n - \"traefik.http.routers.${NAME}-debug.rule=Host(`debug.schoolupdate.c7`)\"\n - \"traefik.http.routers.${NAME}-debug.tls=true\"\n ports:\n - 443:80\n volumes:\n - .\/debug:\/tmp\/xdebug<\/code><\/pre>\n\n\n\nI then need to confirm or configure my own wordpress service and make the xdebug output dir is set. My WordPress service looks like this:<\/p>\n\n\n\n
wordpress:\n container_name: ${NAME}-wordpress\n user: \"1000:1000\"\n build:\n context: \/home\/mklasen\/server-management\/config\/wordpress\n dockerfile: wordpress.Dockerfile\n depends_on:\n - db\n expose:\n - \"9000\"\n volumes:\n - \/home\/mklasen\/server-management\/config\/php\/default.conf:\/usr\/local\/etc\/php\/conf.d\/php.ini\n - .\/:\/var\/www\/\n - .\/debug:\/tmp\/xdebug\n links:\n - db\n external_links:\n - catchall\n environment:\n PHP_AUTOCONF: \/usr\/bin\/autoconf<\/code><\/pre>\n\n\n\nand the xdebug part of my php.ini (not all settings here are relevant):<\/p>\n\n\n\n
xdebug.client_host = localhost\nxdebug.mode = debug,develop,profile,trace\nxdebug.start_with_request = yes\nxdebug.client_port = 9003\nxdebug.idekey=VSCODE\nxdebug.cli_color=2\nxdebug.var_display_max_depth = 10\nxdebug.var_display_max_children = 256\nxdebug.var_display_max_data = 1024 \nxdebug.output_dir=\/tmp\/xdebug<\/code><\/pre>\n\n\n\nAlright, let’s move ahead and restart the docker compose environment with:<\/p>\n\n\n\n
docker-compose stop && docker-compose up -d<\/code><\/pre>\n\n\n\nNow, I did run into some issues like “NOTICE: PHP message: Xdebug: [Profiler] File ‘\/tmp\/xdebug\/cachegrind.out.*’ could not be opened.”<\/p>\n\n\n\n
This was related to the permissions the directory has. After running a chmod -R 777 debug<\/code> on my docker volume folder, this was resolved.<\/p>\n\n\n\nNow, that’s all to really start understanding what’s going on in your PHP web applications,<\/p>\n\n\n\n
Happy developing!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"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: I will […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\n
Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n