Joomla Jumpstart

  • Increase font size
  • Default font size
  • Decrease font size
Home

How to Use TortoiseSVN for Joomla! Template or Extension Development

E-mail Print PDF
User Rating: / 2
PoorBest 

TortoiseSVN logoSource code control (SCC) is extremely useful when developing Joomla templates or extensions because it allows a developer to re-visit past versions. This ability is particularly helpful when a recent change is found to adversely affect performance or operation. Since Joomla requires an extension to be registered into the system before it can be executed, setting up SCC is not as straightforward as with a traditional project. However, with a few extra steps, the process can be a simple one. This example will use TortoiseSVN on Windows to add the working directory of an extension to the SVN system.

TortoiseSVN logo

Create shell versions of your template or extension files


Begin by creating a shell of the extension to be developed. In this case, I'll construct the bare bones of a component called com_contentvacuum for installation. First use your text editor to make a core file such as contentvacuum.php that has a source code similar to this:

<?php
/**
* @version $Id: com_contentvacuum.php 5203 2007-03-27 01:42:10Z Danr $
* @package Joomla
* @copyright Copyright (C) 2007 Dan Rahmel. All rights reserved.
* @license GNU/GPL
* This is a component to allow bulk content import.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

echo "<h1>" . JText::_( 'Hello World!') . "</h1>";

Next create the component's installation descriptor file similar to this contentvacuum.xml:

<?xml version="1.0" encoding="utf-8"?>
<install version="1.5.0" type="component">
     <name>Content Vacuum</name>
     <author>Dan Rahmel</author>
     <creationDate>August 2007</creationDate>
     <copyright>(C) 2007 Dan Rahmel. All rights reserved.</copyright>
     <version>1.0.0</version>
     <description>Content Vacuum component</description>
     <files>
          <filename module="contentvacuum"
>contentvacuum.php</filename>
     </files>
     <administration>
          <menu>ContentVacuum</menu>
         <files>
              <filename module="contentvacuum"
              >contentvacuum.php</filename>         
         </files>
     </administration>
</install>

Place the files inside a folder (this one is called /com_contentvacuum) and compress the two files into a Zip or Tar archive. Use the Install/Uninstall option in the Extension Manager of the Joomla Administrator interface and install the shell into the system. Now comes the interesting part.

Adding the files to your SVN repository


Traditionally in SVN, you first create a repository, upload the initial files into it, and then check out a working copy to your local drive where development will occur. Since Joomla requires installation of the component before it can be tested in the system, you essentially have a working copy first. Therefore, you need to create an empty project in your repository and then add the working copy files to it.

Open the Repo-browser for your repository. If the repository is stored in a folder on your local Windows drive, you can right-click on the folder and select the TortoiseSVN > Repo-browser option. You should see a screen similar to the one shown below.
SVN Repo Browser

Right-click on the repository you will be using for the project and select the Create folder... option. Enter the folder name that matches the name of your extension. For my project, I entered com_contentvacuum and clicked the OK button. The Log window should confirm that the folder was created successfully in the repository.

If you expand the new project item in the Repo-browser, you'll see that it's currently empty. Now you need to return to your operating system and open a window that shows the working folder of your template or extension. The path to a component is likely to be something like this:

 

C:\Program Files\Apache Software Foundation\
  Apache2.2\htdocs\components\com_contentvacuum

 

Right-click on the working folder of the component and select the SVN Checkout... option. Since the current project is empty on the repository, no files will be checked out to the working directory, yet the directory within the Joomla system will be acknowledgement by SVN as a valid working folder.

 

You will be presented with an Import window that allows you to select the URL of the repository from which to check out files. You can use the three-ellipse button (...) to navigate to the folder you created earlier or enter the URL manually such as:

 

file:///C:/SVN_Repository/com_contentvacuum

 

The system will warn you that the target folder is not empty. Click the Yes button to proceed. The folder will now be configured for SVN. Right click on the working folder once more and select the TortoiseSVN > Add... option and the Add window will display all of the files and folders you will be adding. Select the files you want under SCC and click the OK button. That's it! Your extension will be added to the archive.

Each time you want to save a version of the files to your repository, simply right-click on the component folder, select the SVN Commit... option, enter a message that summarizes the changes, and click the OK button.