


You could do this with a make command or Composer script. It's important to note that for this to work with Drush, or anything that exists both in Composer and globally, you need to invoke Drush from the binary in the vendor directory vendor/bin/drush rather than using the system Drush, so that PHPStorm can use the path mappings. In Docker for Windows and Docker for Mac, it automatically resolves to the internal address of the host, letting you easily connect to it from the container. Note that we use the value to refer to the remote host. Check 'Use path mappings', and set a path mapping for the root directory to /var/www/html (or wherever it's mounted to on the container). As you can see, we use the preconfigured Docker image comprising the Apache web server and PHP 7.4 with Xdebug. Give it the appropriate host and port-for docker4drupal the host will be something like, and the port will be 8000 unless you've changed it. Check 'Filter debug connection by IDE key' and set the IDE key to match the one in your XDebug config (for the above we'd use PHPSTORM). Pick the PHP Remote Debug template and click the + on the top left to add a new configuration (don't make the mistake of editing the template). Debug PHP in Docker with PHPStorm and Xdebug Raw README.md Debug your PHP in Docker with Intellij/PHPStorm and Xdebug For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Next click the 'Add configuration' button on the taskbar in the top right. Go to Preferences > PHP, add new interpreter, select new interpreter from Docker, vagrant, etc. Select Docker Compose and the php service, then use the default options for everything else. Here we want to configure our PHP docker interpreter. Click the + on the top left and add a new Docker configuration. Now, we need to ensure that PhpStorm has PHPUnit integration set up. If it is, then PhpStorm is working with a PHP binary that has Xdebug support available. Next, ensure that Xdebug is written next to Debugger, as in the screenshot below. Now go to Settings > Languages & Frameworks > PHP and set your language level as required. Select your version of PHP in the left-hand column. If you enable these after you've created the PHP container, remember to restart the container so that xdebug is enabled and configured. Now when I activate this extension and set phpstorm to listen for incoming. When I go to Preferences -> PHP > Debug and Validate the debugger configuration (as a local web server) this works and gives me the following output: I also installed the browser extension for chrome. PHP_XDEBUG : 1 PHP_XDEBUG_DEFAULT_ENABLE : 1 PHP_XDEBUG_REMOTE_CONNECT_BACK : 0 PHP_IDE_CONFIG : serverName=PHPSTORM PHP_XDEBUG_IDEKEY : "PHPSTORM" PHP_XDEBUG_REMOTE_HOST : 172.17.0.1 # Linux Now as the last thing I tried to set up Xdebug, which isnt working.
