This article or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well. If this article or section
This article provides detailed instructions for setting up your workstation for Joomla! development. Note that there are many possible configurations for doing Joomla! development. Any environment that supports Apache, MySql, PHP, and Subversion should work for writing Joomla! code and extensions.
This document provides step-by-step instructions for setting up and working with Apache, PHP, xdebug, Subversion. This instruction uses Eclipse IDE from chapter 4 and onwards. Please refer to the following links for other development tools:
The example used and screenshots are for Windows XP, but the basic steps are the same for Linux.
Starting with version 1.7, XAMPP includes the XDebug PHP debugger, but it needs to be configured for use. To do that, we will edit the "php.ini" file to configure XDebug. The "Loaded Configuration File" in the screenshot above tells you what "php.ini" file is being used. For Windows, this is normally "c:\xampp\apache\bin\php.ini".
Important note for Windows 7 & Vista users: As of April 2009 (XAMPP version 1.7.0), the file "php_xdebug.dll" that is included with XAMPP does not work with Windows 7 & Vista. The symptom of this problem is that the Apache server will stop if this version of XDebug is loaded. To correct this problem, download XDebug version "Xdebug 2.0.0 / 5.2 VC6" from the XDebug website. This will download a file called
php_xdebug-2.0.0-5.2.2.dll. Save this file in the extensions folder (for example,
c:\xampp\php\ext) and change the php.ini file to point to this file, as shown below. With this file, XDebug works correctly with Windows 7 & Vista, including 64-bit.
We need to edit this file to configure XDebug as follows:
implicit_flush = On
[XDebug] ;; Only Zend OR (!) XDebug zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll" xdebug.remote_enable=true xdebug.remote_host=localhost xdebug.remote_port=10000 xdebug.remote_handler=dbgp xdebug.profiler_enable=1 xdebug.profiler_output_dir="C:\xampp\tmp"
For Windows 7 & Vista, you will use the file downloaded from the XDebug site. So the first line will be
For PHP version 5.3 or later, the "_ts" has been dropped, so the first line will read
In XAMPP 1.7.3 on Windows 7 (currently not verified/tested with prior Windows versions), XDebug may not work correctly if the path to the DLL file is in quotes. In this case, the line should be
zend_extension = C:\xampp\php\ext\php_xdebug-2.1.0-5.3-vc6.dll
We will edit the "php.ini" file to configure XDebug. The "Loaded Configuration File" in the screenshot above tells you what "php.ini" file is being used. For Linux, it will be something like "/opt/lampp/etc/php.ini".
We need to edit this file to configure XDebug as follows:
implicit_flush = On
;xDebug Configuration starts zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so xdebug.profiler_output_dir = "/tmp/xdebug/" xdebug.profiler_enable = On xdebug.remote_enable=On xdebug.remote_host="localhost" xdebug.remote_port=10000 xdebug.remote_handler="dbgp" ;xDebug Configuration ends
If using php5-xdebug on Ubuntu The xDebug Configuration detailed above can be appended to:
It should already contain the "zend_extension" variable and only needs the following variables added:
xdebug.profiler_enable = On xdebug.remote_enable=On xdebug.remote_host="localhost" xdebug.remote_port=10000 xdebug.remote_handler="dbgp"
Tip for users with LAN or remote servers:
Should be set to the IP address of your Eclipse workstation [LAN users] or your public IP. For example:
XAMPP for Mac OS X includes the XDebug PHP debugger, but it needs to be added to the "php.ini" file so that XDebug runs when Apache is started. To do this, open up the php.ini file, located at "/Applications/XAMPP/xamppfiles/etc/php.ini".
We need to edit this file to configure XDebug as follows:
implicit_flush = On
;xDebug Configuration starts zend_extension="/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so" xdebug.profiler_output_dir = "/tmp/xdebug/" xdebug.profiler_enable = On xdebug.remote_enable=On xdebug.remote_host="localhost" xdebug.remote_port=10000 xdebug.remote_handler="dbgp" ;xDebug Configuration ends
Be sure to navigate to the directory where you targeted the extension and check to see that the file path is correct. The folders in your XAMPP installation may be named differently.
The current (as of Sept 2010) version of the XAMPP binary for OS X contains the 2.0.4 version of Xdebug which will not let you see the variable data from included files when running xdebug. You can download a newer version from http://code.activestate.com/komodo/remotedebugging/. Unzip and copy one of the xdebug.so files to /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626. As of Oct 2, 2010 this binary is still out of date (2.1beta3 rather than the stable 2.1) but it will show the variable data appropriately.
Now, we need to check that XDebug is installed correctly. To do this, we need to re-start XAMPP. In Windows, we can just browse to the "c:\xampp" folder in Windows Explorer and double-click the program "xampp-control.exe" to open the application shown below.
Press the "Stop" button for "Apache". The button with then read "Start". Press "Start" for Apache and wait a few seconds and the green "Running" message will again display. Then press "Exit" to close the application.
In Windows, if you get "ERROR: MySQL service not started [-1]", you may be able to correct this by going to c:\xampp\mysql and running mysql_uninstallservice.bat followed by mysql_installservice.bat.
In Linux, to restart XAMPP execute the command
sudo /opt/lampp/lampp restart
In Mac, open the "XAMPP Control" application, stop, and then start the Apache service again.
Once XAMPP has been restarted, open a browser and navigate to "http://localhost" to display the XAMPP welcome message (if you set XAMPP to listen to another port, you must append the port to the url; e.g.:"http://localhost:8080/"). Press the "phpinfo()" link again to display the PHP information screen. Scroll down to the lower part of the screen. You should see a section for "XDebug" as shown below.
Look at the settings you entered in the "php.ini" file above. You should see these same settings in the xdebug display, as shown below.
At this point, XDebug is set up correctly.
Note: Getting XDebug to work on some workstations can be difficult. XDebug is NOT required to be able to use Eclipse for PHP development. If you are new to Eclipse for PHP, you can skip this section and use Eclipse without XDebug if desired. You can install XDebug later if you need it.
The first thing we need to do is to tell Eclipse to use the XDebug we installed earlier. Navigate to Window / Preferences, as shown below. (Mac users: Eclipse / Preferences...)
This will open the Preferences dialog. Expand the PHP node on the left and select "Debug" to display the screen below.
Notice that the "Break at first line" box is checked. This means that the debugger will always break or suspend execution at the first line of code. We'll see this later on when we run the debugger.
Select XDebug for the PHP Debugger. You might get the message below.
If so, just ignore it and press OK. (We're going to change the ports now anyway.)
In order to ensure compatability with php.ini, press the "Configure" link for the PHP Debugger to display the screen below.
Highlight the XDebug line and press Configure to display the screen below.
A Runtime Error has occurred. Do you wish to Debug? Line: 1 Error: Syntax error
If so, you can eliminate these messages by changing the "Output Capture Settings / Capture stdout" from "copy" to "off".
Next, we need to set some options. Select the menu Window / Preferences to open the Preferences dialog. Expand PHP and Debug and select "Workbench Options", as shown below.
Change the settings as shown above. You can experiment with these settings to make Eclipse best for you.
Next, select the "PHP Servers" item on the tree to display the screen shown below.
Select the "Default PHP Web Server" (the only one in the list) and press the Edit button to display the Edit Server dialog shown below.
Recall that we created our workspace, called "joomla_development", under the "c:\xampp\htdocs" directory. So the URLs to the HTML and PHP files in our project will need to include the "joomla_development" directory name (for example, "http://localhost/joomla_development/Test Project/test.php"). If we change this here, Eclipse will create the URLs for us automatically. So complete the screen as shown above and press OK.
Now we finally get to have some fun. We're going to write a simple PHP script and run and debug it to test that Eclipse is set up correctly. If you are already familiar with Eclipse, you can just skip over this section. If not, we'll go through some basics.
First, some quick Eclipse terminology. In Eclipse, we talk about the workbench, perspectives, and views. The workbench is just the whole screen. It has an edit area, where we will edit our PHP files, and a series of views around the outside. A view is an area that displays information about a file or some other resource. A perspective is just a pre-packaged layout of views designed for a specific purpose. When we're writing PHP programs, two perspectives are of interest: the PHP perspective and the PHP Debug perspective.
Let's open the PHP perspective. We can select Window / Open Perspective / PHP, as shown below.
Now the workbench displays a different set of views, including the PHP Explorer, in the upper left, and three views in the lower left. Note that Eclipse has pretty good Help, which you can access by pressing F1 or selecting Help / Help Contents from the menu. The screen below shows some of the contents available, including Getting Started, Basic Tutorials, and other useful information.
Remember that we created a workspace when we launched Eclipse. Before we can write any code, we need to create a project. A project stores a group of related program files. For example, the entire Joomla! application will be one project. We're going to create a test project that we can use to test our setup. We'll select the menu File / New / PHP Project, as shown below.
This will open the first screen in the new project wizard, shown below. Enter the project name, in this case "Test Debug", and press Finish.
Our new project will now show in the PHP Explorer view.
Next, we need to create a PHP file. Select the "Test Debug" project, right click, select New / PHP File, as shown below.
Press the Browse button and select the "Test Project" for the source folder. The New PHP File wizard will display, as shown below. Enter "test.php" for the file name, and press Finish.
An empty PHP file will now display in the editor. Enter the code shown below, and press the Save button in the upper left toolbar to save the "test.php" file.
Now, we're going to execute the script. We'll select the file "test.php" and right-click and select Run As / PHP Web Page, as shown below.
The script will be run in your default browser, and should display as shown below.
If your php files are set by default to open in a text editor, you may get an error. If so, go to Window/Preferences/General/Web Browser and explicitly select your preferred option.
Note that the "phpinfo()" command displays information about your PHP configuration. This is the same screen we saw earlier, when we clicked on the "phpinfo()" link in the XAMPP home page.
Now, let's try debugging this script. Again, select the "test.php" file and right-click, but this time select "Debug As / PHP Web Page", as shown below.
This time, the browser opens and suspends. (Note: If Eclipse does not suspend at the first line, try closing Eclipse and re-starting it.)
Go back to Eclipse and open the PHP Debug perspective by selecting Window / Open Perspective / PHP Debug, as shown below.
This opens the Debug Perspective, with the "test.php" file suspended, as shown below.
Recall from earlier that the "Break at first line" option was selected. This is why the debugger has suspended here, on the first line in our program.
There is a lot going on in this screen. The Debug view in the upper left shows the "frame" information. In this case, we are suspended on line 2. The editor window is now in the middle of the screen. A small blue arrow shows where the program is suspended.
In the upper right is the Variables view. This shows the variables that are in scope at this point in the program.
The toolbar in the Debug perspective is important. The tools are labeled below.
If you are familiar with debuggers from other IDEs, these commands will probably be familiar. If not, you can read more about it in the Eclipse help documentation and experiment on your own.
To finish, let's press the Step Over button. The Debug view and editor now show that we are on line 3. Note that this means that we are about to execute line 3. Also, note the change in the Variables view. Now the variable $mytest has a value of "this is a test" because line 2 has now executed.
Press Step Over again. Now we're on line 4. Look at the browser window. It should now say "this is a test", since now line 3 has executed. Press Step Over again and look at the browser window. Now it shows the output of "phpinfo()".
Finally, press Resume. Notice that the program is no longer suspended and the browser no longer shows that it is waiting to complete the page. The script has completed, but our debugger session is still running.
To close the debugger, select the "Remote Launch" in the Debug view and press the Terminate button. Two things happen. In the browser, a new window launches showing a terminate message. In Eclipse, the PHP perspective automatically displays. This is because we set this in the Debug preferences.
Now we had to manually open the Debug perspective, which is an extra step. We can tell Eclipse to do this automatically for us. We just go to Window / Preferences / Run/Debug / Perspectives, select "PHP Web Page", and check "Always" for "Open the associated perspective when launching", as shown below.
At this point, the XDebug is working correctly in Eclipse.
This can happen if another application is using the port you chose for XDebug. If you experience this problem, try changing the port from 10000 to 10002 or some other value. You have to change the port number in your
php.ini file as well as in the Eclipse preferences. You also have to re-start your Apache server to make the change effective.
Before we can start coding in Joomla!, we need to be able to work with the Subversion (SVN) source code repository. Subversion is a third-party plugin for Eclipse, so we need to use the Eclipse Update Manager to install it. To do this, navigate to Help / Software Updates, as shown below.
The Software Updates and Add-ons dialog will display. Select the "Available Software" tab. The list of available update sites will display. Press the "Add Site" button to display the Add Site dialog. Enter "http://subclipse.tigris.org/update_1.8.x" as the URL, as shown below. NOTE: 1.8 is the current version as of the date of this update: July 20, 2012
Press OK and the "Available Software" tab should again display, this time with additional options from the Subclipse site. Select all Subclipse options as shown below. Then press the "Install" button.
Eclipse will work for a minute and then display the Install window, shown below. Press the "Next" button. A "Review Licenses" window appears. Click "I accept the terms of the license agreements". Now click finish.
After the files have been downloaded and installed, Eclipse will show the message below recommending that you restart Eclipse. Press "Yes" and Eclipse will restart.
Once Eclipse has restarted, we can test that the Subversion plugin is working. Select File / Import as shown below.
Then expand the SVN element in the tree. You should see an option called "Checkout Projects from SVN", as shown below.
At this point, the plugin has been installed successfully. Press "Cancel" to cancel the import. (We'll import the Joomla! project in the next section.)
This article is continued here: Setting up your workstation for Joomla! development -- Part 2. This includes checking out the Joomla! source code, debugging Joomla! from Eclipse, creating patch files, and Eclipse tips and tricks.