remote debug with multiple projects
Hi,
I have a PHP MVC website (site.com), which calls my PHP API (api.site.com) using a cURL call, and I am having trouble debugging between them.
Both are hosted on the same remote server, in separate phpstorm projects, using one virtual-host file with an "Alias" entry.
My php.ini xdebug entry looks like this:
[Xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=mydesktop
xdebug.remote_port=9000
xdebug.idekey="PHPSTORM"
And my .bashrc contains the following:
export PHP_IDE_CONFIG="serverName=myservername"
What I know so far:
-Hitting the "Debug 'site.com'" button will listen for incoming connections for a given IDE key (e.g. 'PHPSTORM'),
-Whereas hitting the "start listening for php debug connections" button will listen for ALL connections
What I do not know:
-I open two PhpStorm windows (one per project). If I try to hit the "Debug" button in both, I get the error "handler with the same session id is already registered". Am I mean to have different IDE keys? If so, how, because right now the IDE key is set in my php config file, and not on a per-project basis.
-If instead of debugging I "start listening for php debug connections" in both projects, the first call is caught and it debugs correctly. But when the cURL call is made the second project does not debug.
I read the following articles but they did not really help:
https://confluence.jetbrains.com/display/PhpStorm/Simultaneous+debugging+sessions+with+PhpStorm
https://intellij-support.jetbrains.com/hc/en-us/community/posts/207030685-Xdebug-with-multiple-projects-at-once-
The first article would suggest that I need to pass a bunch of GET parameters with every request in order to trigger debugging. This is not an ideal solution for several reasons (maintenance, production).
Is there a "standard" procedure for debugging multiple (but related) projects on a remote server? For example, can I set multiple IDE keys on a single server?
If this is possible I will be able to subdivide my app into many microservices, which will be amazing.
Thanks,
Please sign in to leave a comment.
https://confluence.jetbrains.com/display/PhpStorm/Simultaneous+debugging+sessions+with+PhpStorm is the only doc available on this topic, unfortunately.
Thanks Dimitry.
I have it working to an extent. I can have multiple ide-keys by setting the ide-key inside my htaccess files, instead of php.ini. So I have one ide-key per project. This allows me to debug project1, curl call project2, and then debug project2. This on it's own is pretty great.
As Mark mentions in (https://intellij-support.jetbrains.com/hc/en-us/community/posts/207030685-Xdebug-with-multiple-projects-at-once-), calls are slow, but it works.
However, if I want the curl call to synchronously return data to project1, this is not possible. I guess because:
1) the first hit to project1 is a legitimate HTTP request
2) the curl call to project2 is also a legitimate request
3) but the return from the curl call is not a web request
If I can get that last piece working then my dream of debugging microservices will become a reality.
Any advice is appreciated.
Thanks
ok, I have it! I was just missing this piece, as was mentioned in the other post:
I can now debug multiple php projects. This is too awesome.
And if you have a CLI script you can do the same, but you need to set the "DBGP_IDEKEY" environment variable first, e.g.
export DBGP_IDEKEY=MY_PROJECT_NAME
Thanks!
Thank you for the contribution!