Actions

Setting up your workstation for Joomla! development

From Joomla! Documentation

Revision as of 11:47, 10 August 2012 by E-builds (Talk | contribs)

Documentation all together tranparent small.png
Under Construction

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 has not been edited in several days, please remove this template.
This article was last edited by E-builds (talk| contribs) 2 years ago. (Purge)


Contents

Introduction

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.

Install XAMPP

Configuring a XAMPP server for joomla development

Edit PHP.INI File

For Windows

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:

  1. Find the line "implicit_flush" and set it as follows:
    implicit_flush = On
    
  2. Find the section called "[Zend]" and comment out all of the lines by putting a semi-colon (";") at the start of each line.
  3. Find the line: zend_extension = "c:\xampp\php\ext\php_xdebug.dll" and uncomment it out.
  4. Find the "[XDebug]" section and uncomment out all of the lines (except for the first comment line). For Windows, it should look like the example below:
[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

zend_extension_ts="C:\xampp\php\ext\php_xdebug-2.0.0-5.2.2.dll"

For PHP version 5.3 or later, the "_ts" has been dropped, so the first line will read

zend_extension="C:\xampp\php\ext\php_xdebug.dll"

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

For Linux

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:

  1. Find the line "implicit_flush" and set it as follows:
    implicit_flush = On
    
  2. Add the following lines at the end:
;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:

/etc/php5/apache2/conf.d/xdebug.ini 

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:

xdebug.remote_host="localhost"

Should be set to the IP address of your Eclipse workstation [LAN users] or your public IP. For example:

xdebug.remote_host=192.168.0.199

For Mac OS X

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:

  1. Find the line "implicit_flush" and set it as follows:
    implicit_flush = On
    
  2. Add the following lines at the end:
;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.

Test XDebug Installation

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.

Xampp-control.png

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.

Phpinfo xdebug.png

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.

Xdebug settings.png

At this point, XDebug is set up correctly.

Install and configure Eclipse

Configuring Eclipse for joomla development

Install Eclipse Subversion

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.

Eclipse help software updates.png

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

Subclipse update site 1.6.png

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 install update 1.6.png

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.

Eclipse install update2 1.6.png

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.

Eclipse install update3.png

Once Eclipse has restarted, we can test that the Subversion plugin is working. Select File / Import as shown below.

File import.png

Then expand the SVN element in the tree. You should see an option called "Checkout Projects from SVN", as shown below.

Svn checkout projects.png

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.)

Setting up your workstation for Joomla! development -- Part 2

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.