|
A quick and dirty on how to get Eclipse PDT up and running on Leopard, with XDebug debugging.
Install Apache using Macports and PHP using the Configure instructions in my PHP on Leopard article.
Grab XDebug (I grabbed 2.0.3)
Build and install it:
phpize && ./configure --enable-xdebug && make && cp modules/xdebug.so [PATH TO PHP BASE]/lib/php/extensions/no-debug-non-zts-20060613/
Add the following to php.ini:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
zend_extension="[PATH TO PHP BASE]/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
Run php -i and php -m to check for the presence of xdebug.
Restart Apache.
Grab Firefox
Grab Eclipse with PDT pre-configured (I grabbed v1.0.3 RC1)
UPDATE: I've since learned how to do this with Zend Studio for Eclipse (which has Xdebug support disabled by default). Before doing the steps below, do the following from Terminal.app in order to get Xdebug enabled again:
cd /Applications/Zend/Zend\ Studio\ for\ Eclipse\ -\ 6.0.1/plugins
mkdir disabled
mv com.zend.php.debug.* disabled
/Applications/Zend/Zend\ Studio\ for\ Eclipse\ -\ 6.0.1/ZendStudio.app/Contents/MacOS/ZendStudio -clean
After you've done all that from the command line, your XDebug options will be back. You can then quit out and go back to loading up ZSE from the desktop.
|
Launch Eclipse, head to the preferences. (Cmd-,)
Select from the LHS pane: General -> Appearance -> Web Browser
Select "Use external Web browser"
If Firefox shows up on the list, select it and edit as shown below. Otherwise, click "New" and fill in the following:
Name: Firefox
Location: /usr/bin/open
Parameters: -a /Applications/Firefox.app
GOTCHA: If you leave the Firefox configuration as standard without making the above changes, you'll get the error message: "A copy of Firefox is already open. Only one copy of Firefox can be open at a time."
Select from the LHS pane: PHP -> Debug
Set as follows:
PHP Debugger: XDebug
Server: Default PHP Web Server
PHP Executable: Default
Select from the LHS pane: PHP -> Debug -> Installed Debuggers
Click XDebug, Configure.
Ensure "Show super globals in variable view" is ticked, "Use Multisession" is unticked, and port is 9000 (or whatever you set in php.ini)
Select from the LHS pane: PHP -> Debug -> Workbench Options
Select the following: Never, Never, Open in Browser, Open PHP Debug Views
Click OK
Whip up your script and save it. There's an example one below.
Set a breakpoint by double clicking in the blue
The first time you debug, do it as follows:
Menu: Run -> Open Debug Dialog...
On the LHS, select PHP Web Page -> your script name
On the server tab, ensure XDebug is selected as the debugger. The rest of the parameters should be straight forward. Ensure the URL is displayed correctly.
Happy debugging!
GOTCHA: Ensure the following two directives are set in php.ini:
output_buffering = 0
implicit_flush = On
Otherwise you may not see the results output by the script prior to suspending at a breakpoint.
GOTCHA: Safari (3.1.1 anyway) appears to have some sort of input buffering on it. This makes is unsuitable for debugging scripts with small amounts of output. Take the example of the following script:
<?php
print "A<br>\n";
print "B<br>\n";
print "C<br>\n";
print "D<br>\n";
?>
If the breakpoint is set at the third print line and hit "Debug as web page", you'd expect to see:
A
B
Then the script suspend. When you click "Resume", you'd expect to see the rest of the output. If you run it using Firefox as the browser, this is exactly what you see. When running through Safari however, you see no output at all until clicking Resume.
|