Search code examples
phpstormxdebug

PhpStorm - xDebug on demand not attaching


I tried out your new feature "xedbug on demand". I stuck to these guides (https://www.jetbrains.com/help/phpstorm/2016.3/configuring-xdebug.html and https://blog.jetbrains.com/phpstorm/2016/06/xdebug-on-demand-for-cli-php-scripts-in-phpstorm-2016-2-eap/).

I see that in the php Server menu when I add the path to the xdebug that PhpStorm recognizes it (the label switches from "not installed" to "XDebugger 2.4.1").

So everything seems to be fine but when I use the debugger via the bug-icon, it never attaches/stops for the breakpoint.

I activated the xdebug-Logfile, but it stays completely empty.

Furthermore I commented everything xdebug-related out in the php.ini.

The xdebug-port is still on 9000 (default).

Any ideas what I can do about it?

Update: I'm using the debugger via phpStorm's "PHP Web Application" and the debug-icon. I'm debugging php files which are executed via an apache vHost.

PS: Checked IntelliJ forum and Stack posts, didn't find anything helpful though...


Solution

  • "Xdebug in demand" option works for CLI debugging only (Run/Debug Configuration of "PHP Script" type; will also work for other CLI-mode configs, e.g. "PHPUnit") be it local or remote.

    Quote from the aforementioned introduction blog post:

    To use the great new feature, first, you need to disable Xdebug for command line PHP scripts.


    That option does not work for web pages served via web browser (e.g. Apache/nginx/IIS) or when just listening for any incoming debug connections (Zero-config approach) where actual debug is initiated outside of IDE.

    The reason is very simple: when launching debugger for CLI script, IDE launches your php executable (your configured PHP Interpreter, e.g. php.exe on Windows) with additional parameter (-z: check php --help output or here) that can load such additional extension.

    But when you debugging a web page then whole PHP is not controlled by PhpStorm: it's your web server (Apache/nginx/IIS/etc) that communicates with PHP .. and you cannot pass such arguments at this stage.