Debugging PHP over xdebug with Eclipse and Vagrant
This documents the configuration needed to debug FusionForge PHP code under the Eclipse IDE (equipped with the PDT PHP development environment), while executing the code inside the Vagrant-based virtual machine development environment.
This requires :
- sharing the source code between the host and guest
- the activation of the XDebug PHP extension in the VM
Sharing the source code between the host and guest
This is needed so that modifications of the PHP code are instantaneously taken into account in the execution environment.
For this you may for instance add a shared directory in the Vagrantfile, by uncommenting the line :
#config.vm.synced_folder "../src", "/usr/share/gforge"
if you wish to execute the code present in the Git repo from where the vagrant up command is performed
Another option is to perform the following steps before installing the packages built inside the VM (refering to Building and installing FusionForge instructions) :
[... ./build.sh] mkdir /vagrant/usr_share_gforge ln -s /vagrant/usr_share_gforge /usr/share/gforge [... ./install.sh]
This ensures that the PHP code will be extracted in a directory that gets created in the directory where vagrant up was performed on the host
Configuring the PDT environment and VM to use XDebug
Configuring XDebug in the Vagrant VM
Install php5-xdebug in the VM (via vagrant ssh)
sudo aptitude install php5-xdebug
Activate the remote_connect_back option so that Eclipse can pilot XDebug
sudo cat << EOF >> /etc/php5/conf.d/20-xdebug.ini xdebug.remote_enable=1 xdebug.remote_connect_back = 1 EOF
And restart Apache
sudo apache2ctl restart