Phpstorm docker xdebug1/18/2024 ![]() ![]() I’m tweeting under giving talks and offering leadership coaching, consulting and workshops. I strive for building happy, motivated, and productive teams and I’m enthusiastic about Kotlin, clean code, distributed systems, testing and the sociology of software development. ![]() I am Philipp Hauer and I work remotely as a Head of Engineering for commercetools in Leipzig, Germany. Use path mappings: src -> /var/If you only click out of the field, your input will be removed.next to the Servers field to create a new server.Ĭreate a Server Configuration for the PHP Docker container, configure Xdebug as the debugger and the path mapping that fits the folder structure within the PHP container It’s only important that you remember this key because we will use it later for the request to trigger the debugging.Ĭlick on the three dots. I usually choose something like IDEA_DEBUG. To be able to select this configuration, you may need to scroll down in the type selection popup (“Add New Configuration”) and click on “52 items more (irrelevant)” in order to find the type “PHP Remote Debug”.Ĭreate a Debug Configuration in IntelliJ IDEA Ultimate/PhpStorm of the type ‘PHP Remote Debug’ which connects to our PHP Docker container via XdebugĮnter an arbitrary key for Ide key(session id). src:/var/www/html/ ports : - "80:80" Configure IntelliJ IDEA Ultimate or PhpStormĬreate a Run Configuration of the type “PHP Remote Debug”. Version : '2' services : apache_with_php : build. Afterward, we have to configure Xdebug with some properties in the php.ini. Within the Dockerfile we install and enable Xdebug using pecl and docker-php-ext-enable. Therefore, we create an own Docker image based on the PHP/Apache image. Xdebug runs within the PHP container and connects to the Xdebug server controlled by IntelliJ IDEA Ultimate/PhpStorm Install and Configure Xdebug in the PHP Docker Containerįirst of all, we need to install and activate Xdebug in our PHP container. But how can we debug the PHP code running in the container? In this post, I show you how to configure Xdebug in a PHP container and configure IntelliJ IDEA Ultimate or PhpStorm for remote debugging. Running PHP and an Apache in a Docker container is very handy for local development. Configure IntelliJ IDEA Ultimate or PhpStorm.Install and Configure Xdebug in the PHP Docker Container.Add xdebug.profiler_enable=1 to /usr/local/etc/php/conf.d/docker-php-ext-xdebug.Engineering Management, Java Ecosystem, Kotlin, Sociology of Software Development Debugging within a PHP Docker Container using IDEA/PhpStorm and Xdebug.SSH to the PHP container: docker-compose exec php sh.Check the output of the phpinfo() again and make sure that the remote_host value is set to for Mac & Windows 172.17.0.1 for Linux.įollow these steps to enable XDebug Profiler:.If this is not the case, add the following on line 28 to your docker-compose.yml: Make sure that remote_host is set to the correct IP address.(if that doesn't work for your instance, then try inserting into line 2 of themes//template.php) Install and enable Xdebug helper extension in chrome.Īdd phpinfo() exit() to your index.php and refresh your page.For me it was under /app/sites/default/themes/custom/oa_theme/, this is important if you want to debug in your theme's template.php for example. NOTE: Your theme might be in a different place. For CLI script debugging I suggest to override xdebug. Configure PHPStorm “Servers” and add path mapping between local folder to the remote folder. To make this work for PhpStorm, the xdebug.ini file should contain at least two entries: xdebug.remoteconnectback0 (that is, if you want a debugging session triggered from the browser).themes) from cli container to the host e.g. Copy entire /app folder or selected folders (e.g. In order the debug into files, you'll need them to exist on your local machine.Essentially, you want to set the Xdebug IDE port to 9000 and the IDE key to PHPSTORM. There are a few places settings need to be set, so I defer to their help pages. JetBrains, the maker of PhpStorm, has detailed instructions on configuring Xdebug in their IDE. Once added you'll need to destroy your local environment and recreate it. Just restarting won't work for whatever reason. Set PhpStorm to listen to Xdebug on port 9000. LAGOON_ROUTE: &default-url $ĭOCKERHOST: # Docker 18.03+ Mac/Win Add DOCKERHOST: "" for MAC & Window, DOCKERHOST: "172.17.0.1" for Linux and XDEBUG_ENABLE: "true" to docker-compose.yml or create a file.The original version of this page was provided by Gregory Netsas and his colleague Ahmed Jabar on the #australia-nz channel in the Drupal slack.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |