Question

How can I set up debugging for Aptana (PHP), for a project which is hosted on a Vagrant box?

No correct solution

OTHER TIPS

Luckily it's not that difficult

Note

I'm not developing in Aptana Studio 3, so maybe there is another (better) way to accomplish this. I just downloaded it, played with it and got it working to help you out.

VM xdebug set up

First of all make sure you installed xdebug correctly on the VM.

Run

php -v

and look at the info, it should show something like this

PHP 5.5.8 (cli) (built: Jan  9 2014 08:14:44) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Or run

php -m

And search for xdebug in the list.

Next edit the php.ini file and make sure the following lines are present in the file

zend_extension="{PATH TO THE XDEBUG module}" <-- run a simple find /. -name xdebug.so if you are not sure where to find it

xdebug.remote_enable=1 
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.remote_connect_back= 1
xdebug.remote_log="/tmp/xdebug.log"

Save the file and make sure you restart the apache service

Vagrantfile set-up

The next thing you have to make sure is that your Vagrantfile contains the following line

config.vm.network :private_network, ip: "22.22.22.11"

Best explanation what this does is from the Vagrant site it self

Private networks allow you to access your guest machine by some address that is not publicly accessible from the global internet. In general, this means your machine gets an address in the private address space.

Host set-up

The last thing you have to do is edit your hosts file with the following line

22.22.22.11 dev.local <-- Just an example name, make it anything you link

Now you are able to acces your VM by simply opening your browser and go to dev.local

Aptana studio 3 set-up

Go to Window -> Show view -> Servers. Add an "External web server"

Name: Anything you like
Base Url: http://dev.local
Document Root: Browse to your vagrant shared project folder and then select the document root as you specified inside your vhosts config on the VM
Run Command: Leave it empty
Stop Command: Leave it empty

Click ok and return to your Window -> Show view -> Project Explorer

Select a file you want to debug set some breakpoints and then Run -> Debug as -> PHP Server If you are prompted with a dialog where your path is shown you have to correct it to http://dev.local

That's it! You're debugging it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top