IntelliJ, PhpStorm: Debugging with xdebug ignores XDEBUG_SESSION cookie
I used to have this issue when I've "overconfigured" my setup.
- You might want to try adding the XDebug helper extension to chrome
- After adding that go to the plugin's settings and select PhpStorm:
- Try striping down your xdebug config to these values only:
(works on my box)
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
- The PhpStorm config should contain debug port 9000 and [X] Can accept external connections:
- Then you should have listening to debug connections in PhpStorm on:
- Also enable debugging in your browser (via the xdebug helper):
- If the bug icon is green , then if you refresh the page, you should be good to go, and PhpStorm should stop at the first breakpoint.
I had the same problem in PHPStorm 9 while debugging code inside a virtual machine. But first you questions:
Question: Why is the XDEBUG_SESSION cookie being ignored?
Answer: I don't know exactly but I suspect based on that it works when you explicitly specify ?XDEBUG_SESSION_START=PHPSTORM
or "break on first line", it is ignoring the incoming request. It will do it's work but don't stop on break points because it thinks it's not needed for the current request.
My solution
What helped me was adding the remote host name/ip to the xdebug, when debugging for browser call. Or export
those setting when debugging from command line.
for xdebug.ini
xdebug.remote_host=mydomain.local;
xdebug.remote_connect_back = On
for command line usage:
export PHP_IDE_CONFIG=serverName=mydomain.local; php -dxdebug.remote_autostart=1 -dxdebug.remote_connect_back=1 -dxdebug.remote_host=mydomain.local ./script.php
Then setting up path mapping
. To do this go to Settings
-> Languages & Frameworks
-> PHP
-> Server
.
In there select the server you set up e.g. mydomain.local
if existing and enter mydomain.local
as host name, with port 80
and XDEBUG
.
Now check the "Use path mappings" and scroll down to your index.php or some other uniqe entry point you can reach from the browser.
The next one sounds stupid but worked for me. If your index.php
is located under /home/lanoxx/project/index.php
enter the same location under "Absolute path on the server". Then set a breakboint in the index.php
file and load page from browser.