Support

submit a bug report if you need technical support or have questions.

Documentation

Visit the Wiki extensive and up to date documentation at your fingertips.

Contact Me

Missing images/links, any comments, suggestions, need help? Contact me

apache_maven

joomla logo vert color

  I will quickly describe in this post how you can code your component/plugins/modules against a specific version of Joomla! with no effort using Maven for PHP.

The trick I made is to package the whole Joomla distribution in a jar file, and add a Maven dependency to the project. As Joomla, PHPUnit, or any other 3rd party is not a set of class packaged in a jar, the brilliant idea of Maven for PHP is to unpack all these dependencies in the target/phpinc directory automatically AND concatenating this directory to the php setting include_path during compile and test phase. You can do the same using the command line by running:

php -d include_path=

That’s also why, It is very important to not put anything from this directory under version control (add a cvs.ignore or svn properties svn:ignore) as it contains dependencies that have no reason to be put under version control in Maven paradigm (they have to reside in a Maven repository)

So I create a new zip file joomla-1.5.10.jar with a directory inside named ‘Joomla’ that contains a standard binary distribution…this jar is published in artifactory with a groupid org.joomla (arbitrary chosen by me)

Artifactory will generate a default pom.xml. Normally it should contains more meta data and be created by the Joomla team itself. (if they ever support Maven)

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.joomla</groupId>
  <artifactId>joomla</artifactId>
  <version>1.5.10</version>
  <description></description>
</project>

The artifact is deployed and viewable at http://maven.waltercedric.com/artifactory/webapp/browserepo.html

joomla.in.artifactory

With the code below I can bind my component to a new version or old version of Joomla just by modifying the component pom.xml. Note the version number 1.5.10 (the latest version of Joomla! to date)

<dependency>
    <groupId>org.joomla</groupId>
    <artifactId>joomla</artifactId>
    <version>1.5.10</version> 
</dependency>

Test cases classes are directly in the eclipse project under src/test/php (this directory is created by the archetype php5-lib-archetype), In bold, this is how you can import the whole Joomla! framework!

require_once ('PHPUnit/Framework.php');
require_once ('Joomla/index.php');

//I load the PHP class that I would like to test
require_once ('admin/class/logUtils.php');

class LogUtilsTest extends PHPUnit_Framework_TestCase {

//a poor PHPUNit testcase
function testisAnEmail() {

        $LogUtils = new LogUtils();
        $this->assertEquals(true, $LogUtils->isAnEmail("This email address is being protected from spambots. You need JavaScript enabled to view it."));
        $this->assertEquals(false, $LogUtils->isAnEmail("cedric.walterwaltercedric.com"));
        $this->assertEquals(true, $LogUtils->isAnEmail("This email address is being protected from spambots. You need JavaScript enabled to view it."));

    }
}

More to come soon.

comments powered by Disqus

You might like also

Failed opening required PHPUnit/TextUI/TestRunner.php in Maven For PHP
This issue has turn me upside down a long time. In fact in the official Google Group http://groups.google.de/group/maven-for-php/ I was not the only one to have this issue. I did try the following, and it is always good to check first Checking PHP version, Starting Maven with -X for having more debug information Testing it in Eclipse + M2Eclipse on windows, was working there, Comparing calculated PHP include path on Windows and Linux: they were identical in this case Only …
3390 Days ago
Installing Subversion on OpenSuse and Plesk 9
Subversion (SVN) is an open source version control system. It allows users to keep track of changes made over time to any type of electronic data. Typical uses are versioning source code, web pages or design documents. I now host my own private subversion at http://svn.waltercedric.com A required step to be able to build some small project and finish the prototype of Continuous build for Joomla!   …
3667 Days ago
My 2 first Joomla! component in continuous build
Status/Done Build with Maven For PHP in TeamCity SVN repository at http://joomlacode.org/svn/com_securityi1/trunk/ and http://joomlacode.org/svn/com_akobookplus/trunk/ Totally independent of continuous build server (Thanks to MAVEN), so Hudson, Bamboo and Cruise Control are SUPPORTED. …
3682 Days ago
Configuring TeamCity, Maven for PHP for Joomla continuous build
Maven for PHP uses the power of Maven for building, reporting on and creating documentations of PHP projects. It adapts the Maven build lifecycle to the PHP world while fully supporting PHP 4 and PHP 5. PHP for Maven uses PHPUnit for unit testing and doxygen for creating the api documentation. Use a PHP library project to create a library that can be used by other PHP libraries or PHP web projects. Use a PHP web project to create a …
3683 Days ago
No Thumbnail was found
I put some effort the last few days in this new framework. Done: I did document some part of it at http://wiki.waltercedric.com/index.php?title=ContinuousBuildforJoomla TeamCity is installed/configured/documented (windows only) XAMPP is installed/configured/documented (windows only) I also at the same time configured a Puppy Linux VMWare image that will permit to anybody to have a running environment in no time. I am able to unpack all Joomla! versions that are committed in any repository (CVS, SVN, Clearcase) They can be unpacked anywhere on …
3769 Days ago
Installing PHPUnit / Selenium in XAMPP
&160; &160; A small how to install PHPUnit via PEAR in an XAMPP running on a windows box. A prerequisite for a continuous build strategy. PHPUnit is a member of the xUnit family of testing frameworks and provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyze their results. PHPUnit homepage ONLamp.com - Testing PHP Code with PHPUnit Planet PHPUnit Sebastian Bergmann (creator of PHPUnit) Installing XAMPP …
3794 Days ago
ContinuousBuild4Joomla project submitted to JoomlaCode.org
I will commit soon a first draft (alpha) of what is expected to bring continuous build to any Joomla! component (or event to Joomla! core itself ;-)) You are free to join the project, all documentation effort stay at the moment in my WIKI &160; …
3816 Days ago
No Thumbnail was found
Automatic installation of Joomla! runtime environments Main ideas Build is scalable Distributed build management optimize hardware resources utilization by parallelizing product builds within the build agents grid. With build chains support, it is even possible to break down a single build procedure into several parts to run them on different build agents &8212; both in sequence and in parallel &8212; using the same set of sources in all of them. I want to be able to test my components against …
3821 Days ago