Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug PHP Web Application using Aptana

This feels like a really stupid question, but I cannot find any YouTube videos / articles / guides / etc that explain the debugging process in Aptana.

I've found the ones that explain how to install the XDEBUG or ZEND components, and that's all good. Now, how do I use them? I can see all sorts of menus, server configurations, debug configurations, but I cannot find a guide that explains how to actually set about using them.

Is there some sort of "PHP debugging with Aptana for dummies" that would provide a very direct walkthrough, something along the lines of:

  1. This guide starts by assuming you have installed XDEBUG into your Aptana studio, and confirmed it with phpinfo().
  2. Setup a debug configuration by....
  3. Start your debugger by ....
  4. Step through the code by ....

and so on.

It sounds so obvious, but I cannot even find something like that for a different IDE.

Please someone put me out of my misery.

like image 392
Maxcot Avatar asked Jul 19 '13 08:07

Maxcot


1 Answers

Hope this helps someone... heaven alone knows why I've battled so much with it.

I am using Aptana Studio 3, build 3.4.2..... And XAMPP ver 1.8.1 installed on C:\xampp (on a windows machine)

1. Ensure that XDEBUG is PROPERLY installed.

I moved to a new computer, and forgot to check. :(

Open php.ini file under \php directory Make sure the following lines are uncommented (no semicolon)

zend_extension="<Xampp_Home>\php\ext\php_xdebug.dll"
xdebug.remote_host=localhost (change 'localhost' to '127.0.0.1')
xdebug.remote_enable=0 (change '0' to '1')
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000

Save and restart web server.

2. Setup your web server in Aptana under Window > Preferences > Aptana Web Studio > Web Servers.

(I use virtual host containers.)

Name: MyWebServer 
URL: http://MyProject 
DocumentRoot: c:\xamppProjects\MyProject\php

3. Setup the PHP interpreter in Aptana under Window > Preferences > Aptana Web Studio > Editors > PHP > PHP Interpreters.

Add...

Name: XAMPP PHP Debugging 
Executable path: C:\xampp\php\php.exe 
PHP ini file: C:\xampp\php\php.ini 
PHP Debugger: XDebug

Now try it out

In Aptana Studio, select the Debug perspective. Open a browser and fire up your app (http://MyProject) Aptana interrupts with a pop window titled "Incoming JIT debug request" and asks "A remote debug request was received from 'MyProject'. Would you like to break on the first line?"

Select yes, and you're into the debugging.

Once I got to this point, I found the setting of breakpoints and tracing the flow pretty painless.

like image 156
Maxcot Avatar answered Oct 03 '22 18:10

Maxcot