Is there any ways to remote debug with a script which will call itself

I try to remote debug a script which will call itself if any arguments be setted.
I wrote a script called "test.php":

     1  <?php
     2  if (count($argv) == 1)
     3  {
     4      echo "call no arg";
     5      exit();
     6  }
     7  $this_script_path = $_SERVER["SCRIPT_FILENAME"];
     8  echo exec("php $this_script_path") . "\n";
     9  echo "call with arg\n";

I tagged break points at line 9 and line 4, and called the script like this -
     # php test.php whatever
Then I waited for the debugger to stop at line 9 and line 4, but it seems cannot be reached anymore.
What I guess is it will initiate another debug connction when the script calls itself, and this connection would be processed only when the previous connections are done.

According to this kind of situation, is there any good solutions?

Appreciate for your kindly reply :)
Comment actions Permalink

Hi there,

Settings | PHP | Debug | Max. simultaneous connections -- increase the value from default 1 to whatever you require (for your simple example 2 will do) -- works fine for me.

Comment actions Permalink

Awesome! Andriy!
You did solve my problem!
I upgrade the Phpstorm to version 6.0.1 and found this option.

Futher more, the "max simultaneous connections" function works fine with zero-config debug mode(press the phone like button).
But I cannot accept multiple connections via press debug button(Shift + F9).
However, at least it's work now!

Thank you so much!!

Comment actions Permalink

But I cannot accept multiple connections via press debug button(Shift + F9).However, at least it's work now!

Pin debug tab -- new session will be in opened in separate/new tab


Comment actions Permalink

Thanks for your reply.
Yes, I did see the new sessions if I start to debug with the phone like button 圖片 3.png.
圖片 2.png

But I cannot see sessions if I press the debug button to start debugging.
圖片 5.png

圖片 7.png

Comment actions Permalink

When you start listening for debug session via Phone handle icon, IDE will accept incomming connection with ANY key.

When you use Run/Debug Configuration enrty of "PHP Remote Debug" type ... IDE will accept incoming connection with that SPECIFIC key ONLY .. and it cannot launch more than one session with the same ID/KEY.

Also .. the subrequest (the exec line) may simply not have IDE key at all (depends how you have configured it).

Anyway -- you have properly working solution already: if one approach does not work (for whatever reason) you can always use another one. I personally always use that Phone Handle icon for web page/remote debug.

Comment actions Permalink

Cool !
Thanks for your explanation, now I know why it hangs.
Maybe it will be great if Run/Debug Configuration mode can aeecpt connections with same KEY.



Please sign in to leave a comment.