tags:

views:

561

answers:

4

I'm a real newbie when it comes to PHP debugging so forgive my stupidity. I have a simple html form that submits to a PHP script and I want to debug that script and see what's being sent from the form.

My Aptana has two two PHP interpreters installed; Zend Debugger on port 10001 and XDebug on 9000

I have the Firefox Aptana Addon installed

I have my HTML page on the following url, running locally;

http://3i/latest.html

In the IDE I open the PHP script and add some breakpoints, I then open the latest.html and I click on the debug button. It launches the HTML page in a local webserver running at;

http://127.0.0.1:8000/3i/latest.html

I then fill out the form and submit at which point the debugger tells me the JS Debugger has terminated but it doesn't stop at my break points.

I've had a good read around and I can't find anything which helps me, which makes me think it's something pretty easy and I'm being a bit dumb.

A: 

My guess is that you don't have a PHP enabled web server running on your local machine. Aptana 2.0 (unlike Aptana 1.5) does not come equipped with a built in PHP enabled web server. To confirm this, go to your link (http://127.0.0.1:8000/3i/latest.html) in Firefox and view source. If you see the actual PHP source code, that means it isn't being run through a php enabled web server.

There are many good options for PHP web servers out there (e.g. XAMPP, WAMP, EasyPHP, UniServer), do some googling and install one. You'll have to setup an Apache alias to point to your Aptana workspace and you may have to install xdebug separately as well.

Honestly Aptana 2.0 is not a very good PHP IDE. I would stick with Aptana 1.5 which does come equipped with the built-in php enabled web server.

seth
Hi Seth,Thanks for the response. I'm running Apache and PHP 5.2.6, which i installed using WAMP. So the user http://3i/latest.html is running on Apache but when I hit the debug button it loads it into the local webserver running in Aptana.
Nick Lowman
+2  A: 

You say that you have both XDebug and Zend debug installed - did you make the appropriate modifications to your local php.ini? You can't have both running at the same time - debuggers act as application controllers, communicating with your web server and giving it orders to stop, pause, or continue execution of your script and having two of them configured at the same time can cause unexpected debugging behavior like you described.

Assuming you want XDebug, you would open up php.ini, search for [XDebug] (or [Zend]). Comment out all the zend_* options and put the following options in:

[XDebug]
;; Only Zend OR (!) XDebug
zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"

Yes, I know I'm on Windows at the moment - don't splutter. Replace the extension path with the appropriate path to XDebug on your server. If you are wanting to use Zend Debugger then it is much the same, just disable XDebug. Don't forget to restart your web server.

EDIT - I may have been unclear; you can have both installed, you just can't have both running at the same time.

Jarrod
Hi Jarrod, I've done that. Now, how do I configure Aptana? Below is the info in my php.ini zend_extension_ts = D:\WAMP\bin\php\php5.2.6\ext\php_xdebug-2.1.0RC1-5.2-vc6.dll xdebug.remote_enable=true xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.profiler_enable=1 xdebug.profiler_output_dir="D:\WAMP\tmp"
Nick Lowman
Do I now have to add that as a PHP interpreter in Apatana. When I click the debug button it uses the local Aptana xdebug executable which exists in the Aptana plugins folder.
Nick Lowman
There should be a screen in Aptana called "Edit PHP Interpreter". You'll need to change the executable path to your own Xdebug installation and change the path (if you haven't already) to the INI file you want to use.Basically, you need to establish your XDebug as a debugging server (and aim at the correct port) in Aptana, and hit that server when debugging.
Jarrod
@Jarrod - I tried that but I don't know what my executable path is? I pointed it the php_xdebug-2.1.0RC1-5.2-vc6.dll but that didn't work.
Nick Lowman
K, run phpinfo(); on a page and double check that xdebug is installed and running. Also - what version of Aptana are you running? Is it using the old PHP plugin or the new PDT plugin?
Jarrod
@Jarrod - I ran phpinfo() and xdebug is enabled and working. Aptana Studio, build: 2.0.4.1268158907 and I'm running the Aptana PHP 1.1 Development environment. I had installed a PDT plugin but it didn't work at all so Apatana support suggested i uninstall that and install PHP 1.1 Development environment.
Nick Lowman
+1  A: 

Here is a nice tutorial explaining how to setup debugging on Aptana

Phill Pafford
Hey Phil, Thanks for the link. I'd already been through the help on their site and I hadn't had much luck. That said, I haven't seen that one as I didn't know it was called remote debugging when you try to debug a web page so I will give it a go when I'm in work tomorrow.
Nick Lowman
Hey Phil, you would happen to know what the difference between starting an XDebug session and starting a XDebug Profiler?
Nick Lowman
Hey Phil, I followed that tut and it was pretty helpful. I think I'm getting near but when I run the debug button I get a message telling me it's 'Waiting for xdebug session'at 57% and that's it. Any ideas?
Nick Lowman
I think I've seen that bug, Did you restart Apache and check the phpinfo() to see if XDebug is configured?
Phill Pafford
Also I noticed you said you're running WAMP so in your configuration you might want to check for this on Windows: zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"or this for Linux: zend_extension="\xampp\php\ext\php_xdebug.dll"
Phill Pafford
Hey Phil, there is a zend_extension_ts line but I added it after following that tut on their site. The XDebug is configured and phpinfo says it's OK but Aptana studio doesn't like it.
Nick Lowman