Eclipse PHP XDebug
I've been developing in PHP recently, and the code base is getting large enough that debugging by using print statements is getting unmanageable. I decided to try the Eclipse IDE for PHP.
I went to the Eclipse PDT page and downloaded the windows Eclipse IDE package for PHP which is supposed to contain everything you need.
Should be quick, right? This is what I did:
- Unzipped the zip file
- Start up Eclipse
- Created a PHP project, and imported some of my existing php files from the file system (in Navigator, right click on the project node > Import > General > File System etc).
- PHP Interpreter is "5.1/5.2" (I have 5.2.5 installed).
- PHP Executable fields are:
- Executable path:
C:\Program Files\PHP\php.exe
(THIS IS WRONG!) - PHP ini file (optional):
C:\Program Files\PHP\php.ini
- SAPI type:
CLI
- PHP Debugger:
XDebug
Then I right-clicked on a standalone test php file and tried to debug it as a script. No joy, I got a pop up dialog with the message "Error launching 'test'. The session could not be started. In order to generate debug information, please make sure that the debugger is properly configured as a php.ini directive."
I then spent about 2 hours trying to figure out how to get this to work, and nearly gave up.
I finally solved the problem by setting the "Executable path" above to
C:\Program Files\PHP\php-win.exe
. Yeesh. I don't know how you're supposed to figure this one out other than trial and error. Running php.exe -i
from a DOS prompt works, although it does cause an error window to pop up. Running php-win.exe -i
from a DOS prompt works without error.Once that was changed, I was able to run and debug my script with breakpoints set!