IntelliJ, PhpStorm: Debugging with xdebug ignores XDEBUG_SESSION cookie
intellij-idea, php, phpstorm, xdebug
Solution
As it turned out the problem was not in IntelliJ or PhpStorm, but rather Drupal specific. In particular I needed to disable all caching.
The article Disable Drupal 8 caching during development explains in detail the steps to do that.
After I had disabled the caching Drupal everything worked as expected.
Problem
I am trying to debug a Drupal website with the PHP plugin in Intellij (would be the same in PhpStorm). I have the following setup: Chrome Browser pointing to a localhost alias `mydomain.local` and the XDebug Helper extension is installed and set to Debug. In the Developer Tools under Cookies I can see that the `XDEBUG_SESSION` cookie is set to PHPSTORM. I have configured php with the xdebug plugin using the following settings: ``` xdebug.extended_info = 1 xdebug.idekey = "PHPSTORM" xdebug.max_nesting_level = 500 xdebug.remote_autostart = 1 xdebug.remote_connect_back = 0 xdebug.remote_enable = 1 xdebug.remote_handler = dbgp xdebug.remote_host = 127.0.0.1 xdebug.remote_mode = req xdebug.remote_port = 9000 ``` In IntelliJ I have setup a Server pointing to `mydomain.local` and in the run configuration I am using that server and have set the Ide Key to `PHPSTORM`. Now the issue is this: If I enable Break at first line in PHP scripts, then the debugger immediately breaks at the first breakable location inside the `index.php`. If I disable that option, I get a warning that no breakpoint was hit, even though I have a break point set and I am certain that the code is being executed. The warning that I see looks like this: ``` Debug session was finished without being paused It may be caused by path mappings misconfiguration or not synchronized local and remote projects. To figure out the problem check path mappings configuration for 'mydomain.local' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu). ``` Now if I explicitly use a URL with the following query parameter appended: `?XDEBUG_SESSION_START=PHPSTORM` then all my breakpoints are properly being breaked in IntelliJ. Question: Why is the `XDEBUG_SESSION` cookie being ignored? Update: Added my PHP and XDebug version output from `php -v`: ``` PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans ``` and my Apache virtual host configuration: ``` <VirtualHost *:80> DocumentRoot /var/www/html/mydomain ServerName mydomain.local <Directory /var/www/html/mydomain> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/mydomain.log </VirtualHost> ``` Update 2: I have a php extension installed that is called `fpm`. I am not quite sure why its installed or if I need it. I think it was automatically installed with php. Could this be interfering?