jbeginners:linux-ideTable of Contents
Integrated Development Environment - LinuxThese instructions were adapted from Malibu’s “Local workstation xampp/Eclipse PDT/xdebug on Ubuntu Linux from start to end” article. Install and configure the test serverStep 1: Download XAMPPYou can download xampp for Windows here: XAMMP for Linux Step 2: Install XAMPPUncompress 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 <xamppHome> -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 testExecute 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: <?php phpinfo(); ?> 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.iniLinux users may need to do the following:
$ 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 xdebugExecute 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 IDEStep 6: Download Eclipse PDTEclipse PDT is a version of Eclipse that is bundled specifically for PHP developers. It’s a good place to start. 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 their web site or if you are using Ubuntu, use the package manager to install sun-java6-bin. Step 7: Install Eclipse PDTUncompress 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 <eclipseHome>. Create the workspace directory: mkdir <eclipseHome>/workspace Step 8: Download Eclipse xdebug pluginYou 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 <xamppHome>/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 workspaceThis 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 <eclipseHome>/workspace Also, From: <Directory "/opt/lampp/htdocs"> To: <Directory "<eclipseHome>/workspace"> Because you have changed httpd.conf, you should restart xampp now. $ sudo /opt/lampp/lampp restart Step 10: xdebug configuration within EclipseFire up Eclipse by executing the appropriate binary in /home/<your_username>/eclipse. When it asks you about the workspace, change it to /home/<your_username>/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. Create a test projectStep 11: Create a PHP ProjectYou’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: <?php phpinfo(); ?> 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 profileYou 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: 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 pluginsStep 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. |



