Configuring PhpStorm + XDebug
I've read through the various articles in this forum and cannot find one that solves my problem. This is the first time I've used XDebug, so please forgive if these are trivial questions.
First, the prerequisites:
- IDE: PhpStorm
- Server: Debian Lenny with PHP 5.3.10 (xdebug module loaded) and Apache 2.4
- Must tunnel XDebug over SSH
- Multiple developer environment at multiple locations
- Using pydbgproxy for handling DBGp
Here's my XDebug configuration on the server:
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.remote_handler=dbgp
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_log="/home/site/xdebug.log"
xdebug.overload_var_dump=1
xdebug.trace_format=0
xdebug.show_exception_trace=0
xdebug.default_enable=0
Set up PHP Remote Debug in the IDE:
IDE key: PHPSTORM
The register IDE successfully
Here are the step that I take to set a breakpoint:
1. SSH into server, launch pydbgproxy
2. Start an SSH tunnel using: ssh -L 9001:localhost:9001 me@myserver.com
3. Set up PHP Remote Debug in the IDE:
IDE key: PHPSTORM
Register IDE (this is successful)
3. Launch editor, set break point on first line
4. Start debug in IDE, message says "Waiting for incoming connection with ide key 'PHPSTORM'"
4. In browser, go to my page (at which the breakpoint lies), append XDEBUG_SESSION_START=PHPSTORM to the URL
Nothing happens. Any ideas of what I'm doing wrong?
Please sign in to leave a comment.
Hi Andrew,
Have you seen this thread? It has some general links on this subject + info on issues that person had and how he sorted it out: http://devnet.jetbrains.net/thread/434136
Another possible reason: path mappings (that's when xdebug connection is successfull, but no path mappings is setup and PhpStorm is unable to figure out which file is requested).
About your workstation OS -- it's xdebug/proxy who initiates connection so maybe your local firewall is blocking connection. Can you connect from server (or another place) to your computer (where you have PhpStorm running) on Xdebug port (using telnet, for example)?
I've tried the wildcard route and it's still not working. I've also set up the path mappings properly as far as I know.
As far as the connection back goes, I'm using an SSH tunnel to handle this, and I want the debugger proxy to connect to the localhost as it's doing:
INFO: dbgp.proxy: dbgp listener on 0.0.0.0:9000
INFO: dbgp.proxy: IDE listener on 0.0.0.0:9001
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 51176) [proxyinit -p 9000 -k PHPSTORM -m 1]
Unfortunately I have nearly zero experience with SSH & tunneling and cannot be of help here.
If it's possible -- just for testing purposes -- can you try setting it up without SSH tunnel (make some virtual server and test there). First: without any proxy (maybe the mistake is in xdebug proxy configuration). When everything is working -- do with proxy. next -- try with SSH. Possibly it's some misconfiguration (or even incorrect approach) when using SSH (or just small typo somewhere). I think -- if it does not work as desired straight away (and I did not had such previous experience), then I would start with simplest thing, make it work and then move to next milestone.
Another thought (although very unlikely as you seems to know what you are doing) -- xdebug / xdebug proxy is the one that initiates connection to debug client (PhpStorm). Maybe (just maybe) your local firewall (or firewall on router or whatever else you may have there) does not allow creating incoming connection on xdebug port?
P.S.
If you still will not be able to resolve it here, then I may suggest asking this question on ServerFault ( http://serverfault.com/ ) or StackOverflow ( http://stackoverflow.com/ )
Maybe you have see these already:
phpstorm still listens on port 9000 not 9001
i think you need to fix your port forward
ssh -L 9001:localhost:9001 me@myserver.com
or change your xdebug listen port in phpstorm:
Project Settings -> PHP -> Debug -> Xdebug -> Debug Port
did you configured your path mappings in phpstorms server config?
Edit: just read you did. it should look something like /srv/www/domain/htdocs/
Edit2:
just noticed there is a xdebug proxy configuration (never needed to use this yet ;) )
Project Settings -> PHP -> Debug -> Xdebug Proxy
did you configured this to your needs?
Hi, Andrew,
Do you still have the issue with debugging?
Thank you for feedback!
Hi Nikolay,
Yes, I've temporarily given up on that approach and run the development site locally with XDebug. However, I would still like to centralize development with the aforementioned requirements.
Andrew,
Did you try to debug your remote application without pydbgp? Let's try to find out the cause of your problem. First of all we need to be sure that it isn't the pydbgp who breaks the workflow.
Please set up your Xdebug using the following configuration:
Then please try to initiate a debug session and let me know about results.
Thank you for feedback!
I created a tutorial based on a smattering of information I found on these support forums and the web.
http://matthardy.net/blog/configuring-phpstorm-xdebug-dbgp-proxy-settings-remote-debugging-multiple-users/
Hopefully it saves someone time! Comments welcome.
Thanks! Your contribution is appreciated!
We also tweeted about it from @webide
Thanks for checking out the tutorial and thanks for the tweet. I'll follow you.