=======Integrated Development Environment - Linux=======
These instructions were adapted from Malibu's "[[http://malibugarage.blogspot.com/2007/07/local-workstation-xamppeclipse.html|Local workstation xampp/Eclipse PDT/xdebug on Ubuntu Linux from start to end]]" article.
===== Install and configure the test server =====
==== Step 1: Download XAMPP ====
You can download xampp for Windows here:
[[http://www.apachefriends.org/download.php?xampp-linux-1.6.3b.tar.gz|XAMMP for Linux]]
==== Step 2: Install XAMPP ====
Uncompress the file you downloaded. Inside you will find a 'lampp' directory. Use sudo to move this into /opt on your machine. This is where xampp is pre-configured to go.
sudo mv lampp/ /opt
Because XAMPP runs as user nobody, you'll have to change the ownership of the files in /opt/lampp by executing
sudo chown -R nobody:users /opt/lampp/*
sudo chmod 777 /opt/lampp/htdocs
If you do not place it in /opt you will need to use a command like this:
# sudo find -type f -exec fgrep /opt/lampp {} /dev/null \;
To root out all the config files that need to have their path altered.
==== Step 3: Start XAMPP and test ====
Execute
sudo /opt/lampp/lampp start
Swing a browser on your xampp machine to 'http://localhost' to test the installation. You should see a flashy splash screen.
You might also want to put a file called phpinfo.php in your htdocs directory. You'll want it to have the following contents:
Hit the page 'http://localhost/phpinfo.php' and you've just executed a php script that tells you all about your php installation.
==== Step 4: Download xdebug server, install it and configure php.ini ====
[[http://www.xdebug.org/link.php?url=xdebug200|Download Xdebug server.]]
Linux users may need to do the following:
* Download the file
* Install phpize (may need to install package php5-dev to get it)
* sudo apt-get install php5-dev
* Uncompress the file and navigate to the directory (as of the time of this writing, the directory is called xdebug-2.0.0)
* Execute:
$ phpize
$ ./configure --enable-xdebug
$ make
$ sudo cp modules/xdebug.so /opt/lampp/lib/php/extensions
$ sudo chown nobody:users /opt/lampp/lib/php/extensions/*
In /opt/lampp/etc/php.ini, make the following configuration changes:
- set 'implicit_flush = On'
- Add the following to the end of the file:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
zend_extension="/opt/lampp/lib/php/extensions/xdebug.so"
==== Step 5: Restart xampp and test xdebug ====
Execute
sudo /opt/lampp/lampp restart
Now browse to http://localhost/phpinfo.php. You should see a section for xdebug. This means that the xdebug extension is running properly.
===== Install and configure the IDE =====
==== Step 6: Download Eclipse PDT ====
Eclipse PDT is a version of Eclipse that is bundled specifically for PHP developers. It's a good place to start.
[[http://www.eclipse.org/downloads/download.php?file=/tools/pdt/downloads/drops/S20070815-M2/all-in-one/pdt-all-in-one-incubation-S20070815_M2-linux-gtk.tar.gz|I recommend the latest integrated test version.]]
It is the 'all-in-one' package for your platform. It's Java, so at it's heart it is platform independent, but it uses widgets that are platform specific.
A note about Java: It is very important to have the latest vm installed before trying to use Eclipse PDT. You can verify that you have the latest shiny version of Java by going to [[http://www.java.com|their web site]] or if you are using Ubuntu, use the package manager to install sun-java6-bin.
==== Step 7: Install Eclipse PDT ====
Uncompress the file you just downloaded. Somewhere inside there you will find a directory called 'eclipse'. Move that into the home directory of the non-root user you will be developing under, or some directory under that home. From here on in I will refer to this directory as .
Create the workspace directory:
mkdir /workspace
==== Step 8: Download Eclipse xdebug plugin ====
[[https://bugs.eclipse.org/bugs/attachment.cgi?id=74296|You want the 'Prebuilt Binary V0.2.3']].
This is the plugin that will allow us to configure Eclipse to use XDebug.
Extract the file and move the two jar files within into the /eclipse/plugins directory. It's also a good idea to print out the pdf and read through it. There is a lot of good information there.
==== Step 9: Point Apache into the Eclipse workspace ====
This is an optional step but it makes for an easier experience. If this is to be purely an Eclipse/xdebug workstation, it's best to change the xampp Apache DocumentRoot so that it will look to the Eclipse workspace for any web page that you open. Edit /opt/lampp/etc/httpd.conf and change the following:
From:
DocumentRoot /opt/lampp/htdocs
To:
DocumentRoot /workspace
Also,
From:
To:
/workspace">
Because you have changed httpd.conf, you should restart xampp now.
$ sudo /opt/lampp/lampp restart
==== Step 10: xdebug configuration within Eclipse ====
Fire up Eclipse by executing the appropriate binary in /home//eclipse. When it asks you about the workspace, change it to /home//eclipse/workspace. You can check the "Don't ask me later" mark; it's really easy to change again later.
When Eclipse starts, go to Window->Preferences.. PHP->debug. The pane should look like this.
(Notice the xdebug section). I didn't actually have to change anything here, as it's all in the php.ini.
{{http://www.bluejacketsoftware.com/images//narrow%20preferences%20.png}}
===== Create a test project =====
==== Step 11: Create a PHP Project ====
You're finally ready to debug a web-based PHP script. Without further ado, within Eclipse select File->New->Project.. Now PHP->PHP Project.
For 'Project Name', enter 'debugtest' and then select 'Finish'. You will see the project pop up in the PHP Navigator. Highlight the project. Select File->New->PHP File and name it phpinfo.php (ok I'm not feeling very original here).
In the editing pane, make sure the file contents are:
Note: Newlines get ignored.
Save the file.
Navigate to http://localhost/debugtest/phpinfophp. You should see the same info you saw before.
==== Step 12: Configure your debug profile ====
You must now go into Eclipse and tell the xdebug plugin how to start a debug session so that you can catch a breakpoint in your new script. Select Run->Open debug dialog.. and double-click on 'PHP Web Page with Xdebug'.
NOTE: There must be menu items 'PHP Exe script with XDebug' and 'PHP Web Script with XDebug'. If these aren't there then something has gone wrong with the plugin installation.
You will come to a dialog screen that looks like this:
{{http://www.bluejacketsoftware.com/images//narrow%20preferences%20.png}}
Under Script and Server, browse to the file phpinfo.php in project debugtest.
Make sure the url field has http://localhost/debugtest/phpinfo.php. If it doesn't, uncheck the box and edit it manually. This is important because it is the site that Eclipse will go to when you start your debug session.
**//It's important to note//** that the configuration you just created is exclusively for the debugtest project. You will have to repeat this procedure and create a new debug profile for every new project you start. These configurations are unique to each project so it makes sense to name them accordingly.
Select 'Apply' and 'Debug'.
You should have seen your phpinfo output come up in the external browser. Now select the tab for phpinfo.php and right-click on the vertical bar between your phpinfo.php line numbers and the edge of the edit pane and select 'Toggle Breakpoints'. You will see a blue circle appear, indicating that there is a debug breakpoint at that location.
Click on the down-arrow next to the bug in the top toolbar and select the debug test session that you just created.
You should now have caught your first breakpoint.
===== Install additional plugins =====
==== Step 13: Install the Subclipse plugin. ====
Within Eclipse, select Help->Software Updates->Find and Install..
Select 'Search for New Features to Install'. Hit 'Next'.
Select 'New Remote Site..'
Name: Subversion
Url: http://subclipse.tigris.org/update_1.2.x
Now on the main screen ensure Subclipse is checked. Hit 'Finish' and follow the instructions to install Subclipse.
When you are done, you will have a 'SVN Repository Exploring'. You can use it to connect to your repository and do all the operations you need to.