{"id":1253,"date":"2022-09-29T12:51:38","date_gmt":"2022-09-29T12:51:38","guid":{"rendered":"https:\/\/mklasen.com\/?p=1253"},"modified":"2022-09-29T12:51:43","modified_gmt":"2022-09-29T12:51:43","slug":"setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling","status":"publish","type":"post","link":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/","title":{"rendered":"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling"},"content":{"rendered":"\n

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.<\/p>\n\n\n\n

We’ll use the Geniem Oy’s images and repo<\/a> for the foundation. I’m specifically interested in the webgrind service, and will add this to my docker-compose.yml file:<\/p>\n\n\n\n

webgrind:\n  image: devgeniem\/webgrind\n  ports:\n    - 80\n  volumes_from:\n    - web<\/code><\/pre>\n\n\n\n

I 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\n

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:<\/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\n

and 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\n

Alright, 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\n

Now, 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\n

Now, 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":"\nSetting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen\" \/>\n<meta property=\"og:description\" content=\"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 […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\" \/>\n<meta property=\"og:site_name\" content=\"Marinus Klasen\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-29T12:51:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-29T12:51:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mklasen.com\/content\/uploads\/2020\/03\/cropped-cropped-mklasen-logo-margin-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Marinus Klasen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/marinusklasen\" \/>\n<meta name=\"twitter:site\" content=\"@marinusklasen\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marinus Klasen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\"},\"author\":{\"name\":\"Marinus Klasen\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"headline\":\"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling\",\"datePublished\":\"2022-09-29T12:51:38+00:00\",\"dateModified\":\"2022-09-29T12:51:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\"},\"wordCount\":204,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"articleSection\":[\"General\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\",\"url\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\",\"name\":\"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/#website\"},\"datePublished\":\"2022-09-29T12:51:38+00:00\",\"dateModified\":\"2022-09-29T12:51:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mklasen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\/\/mklasen.com\/general\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mklasen.com\/#website\",\"url\":\"https:\/\/mklasen.com\/\",\"name\":\"Marinus Klasen\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mklasen.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"nl-NL\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\",\"name\":\"Marinus Klasen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"width\":1500,\"height\":1000,\"caption\":\"Marinus Klasen\"},\"logo\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\"},\"description\":\"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter\",\"sameAs\":[\"http:\/\/facebook.com\/marinus.klasen\",\"https:\/\/nl.linkedin.com\/in\/marinusklasen\",\"https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/","og_locale":"nl_NL","og_type":"article","og_title":"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen","og_description":"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 […]","og_url":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/","og_site_name":"Marinus Klasen","article_publisher":"http:\/\/facebook.com\/marinus.klasen","article_author":"http:\/\/facebook.com\/marinus.klasen","article_published_time":"2022-09-29T12:51:38+00:00","article_modified_time":"2022-09-29T12:51:43+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/mklasen.com\/content\/uploads\/2020\/03\/cropped-cropped-mklasen-logo-margin-1.png","type":"image\/png"}],"author":"Marinus Klasen","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/marinusklasen","twitter_site":"@marinusklasen","twitter_misc":{"Written by":"Marinus Klasen","Est. reading time":"2 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#article","isPartOf":{"@id":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/"},"author":{"name":"Marinus Klasen","@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"headline":"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling","datePublished":"2022-09-29T12:51:38+00:00","dateModified":"2022-09-29T12:51:43+00:00","mainEntityOfPage":{"@id":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/"},"wordCount":204,"commentCount":0,"publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"articleSection":["General"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/","url":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/","name":"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling - Marinus Klasen","isPartOf":{"@id":"https:\/\/mklasen.com\/#website"},"datePublished":"2022-09-29T12:51:38+00:00","dateModified":"2022-09-29T12:51:43+00:00","breadcrumb":{"@id":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mklasen.com\/setting-up-xdebug-and-webgrind-in-docker-compose-for-in-depth-php-profiling\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mklasen.com\/"},{"@type":"ListItem","position":2,"name":"General","item":"https:\/\/mklasen.com\/general\/"},{"@type":"ListItem","position":3,"name":"Setting up xdebug and Webgrind in docker compose for in-depth PHP profiling"}]},{"@type":"WebSite","@id":"https:\/\/mklasen.com\/#website","url":"https:\/\/mklasen.com\/","name":"Marinus Klasen","description":"","publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mklasen.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"nl-NL"},{"@type":["Person","Organization"],"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29","name":"Marinus Klasen","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/","url":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","width":1500,"height":1000,"caption":"Marinus Klasen"},"logo":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/"},"description":"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter","sameAs":["http:\/\/facebook.com\/marinus.klasen","https:\/\/nl.linkedin.com\/in\/marinusklasen","https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Marinus Klasen","author_link":"https:\/\/mklasen.com\/author\/mklasen\/"},"_links":{"self":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/1253"}],"collection":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/comments?post=1253"}],"version-history":[{"count":2,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/1253\/revisions"}],"predecessor-version":[{"id":1255,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/1253\/revisions\/1255"}],"wp:attachment":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/media?parent=1253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/categories?post=1253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/tags?post=1253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}