Support

Forums

Contact Me

Configuring TeamCity, Maven for PHP for Joomla continuous build

apache_maven

Doxygen phpDocumentator phpunit-logo teamcity512 maven4php

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 standalone web project.

So I quickly describe what I did install on my root server (OpenSuse 11.X)

My Objectives: being able to build all my Joomla! component using best agile development practices

“Specific tools and techniques such as continuous integration, automated or xUnit test, pair programming, test driven development, design patterns, domain-driven design, code refactoring and other techniques are often used to improve quality and enhance project agility.”

Maven

While not needed as TeamCity has an integrated Maven engine, I would like to use an external MAVEN version, in order to have the latest version and living dangerously on the edge!

So I download

# wget http://apache.mirror.testserver.li/maven/binaries/apache-maven-2.1.0-bin.tar.gz

And unpack

# tar xvf apache-maven-2.1.0-bin.tar.gz

Since I would like to avoid having a version number in my configuration build path, I create a symlink

# ln -s apache-maven-2.1.0 maven

I just now tell TeamCity to use my own Maven version, by specifying the Maven Home Path

teamcity.maven4php 

phpDocumentor

phpDocumentor is an open source documentation generator written in PHP. It automatically parses PHP source code and produces readable API and source code documentation in a variety of formats. phpDocumentor generates documentation based on PHPDoc-formatted comments and the structure of the source code itself. It supports documentation of both object-oriented and procedural code. phpDocumentor can create documentation in HTML, PDF, CHM or Docbook formats.

Can be installed using PEAR, simply run

# pear upgrade PhpDocumentor
downloading PhpDocumentor-1.4.2.tgz ...
Starting to download PhpDocumentor-1.4.2.tgz (2,421,028 bytes)
..............................................................................done: 2,421,028 bytes
upgrade ok: channel://pear.php.net/PhpDocumentor-1.4.2

PHPUnit

PHPUnit is a unit testing framework for the PHP programming language. Created by Sebastian Bergmann, PHPUnit is one of the xUnit family of frameworks that originated with Kent Beck's SUnit.

Can be installed using PEAR, simply run

# pear upgrade PHPunit

DOxygen

Doxygen is a documentation generator for C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, and to some extent D. It runs on most Unix-like systems, including Mac OS X, as well as on Windows. The first version of Doxygen borrowed some code of an old version of DOC++; later, the Doxygen code was rewritten by Dimitri van Heesch. from www.doxygen.org

# zypper se doxy
Lese installierte Pakete...

S | Name       | Zusammenfassung                                    | Typ 
--+------------+----------------------------------------------------+------
  | doxygen    | Automated C, C++, and Java Documentation Generator | Paket
  | doxywizard | Graphical User Interface for Doxygen               | Paket

# zypper in doxygen

Herunterladen von Paket doxygen-1.5.5-17.1.x86_64 (1/1), 2,3 M (6,2 M installiert)
Lade herunter: doxygen-1.5.5-17.1.x86_64.rpm [fertig] 
Installiere: doxygen-1.5.5-17.1 [fertig]

Artifactory

Prepare Artifactory by adding new Maven for PHP repositories

At http://maven.waltercedric.com/artifactory/webapp/repositoryconfig.html

As Admin user (you cant go to that links without being an admin!), add 2 new repositories

teamcity.maven4php.artifactory

In Maven settings.xml

In order to use Artifactory at his best (proxy and caching of remote repositories), I have a Maven settings.xml that contains ONLY

# vi /home/teamcity/.m2/settings.xml

<activeProfiles>
  <activeProfile>cedric-profile</activeProfile>
</activeProfiles>

<profiles>
   <profile>
        <id>cedric-profile</id>
        <activation>
        <activeByDefault>true</activeByDefault>
        </activation>
<repositories>
    <repository>
        <id>central</id>
        <url>http://maven.waltercedric.com/artifactory/repo/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>snapshots</id>
        <url>http://maven.waltercedric.com/artifactory/repo/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <url>http://maven.waltercedric.com/artifactory/plugins-releases/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>snapshots</id>
        <url>http://maven.waltercedric.com/artifactory/plugins-snapshots/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>
    </profile>
  </profiles>
</settings>

Attention: Artifactory WIKI tell to use http://maven.waltercedric.com/artifactory/plugins-releases and not http://maven.waltercedric.com/artifactory/plugins-releases/ on my HOST with mod_proxy it made an error 404 If I do not add a slash at the end. Try with your host before, you will gain a lot of time by checking if the URL is valid!

Note that http://url:port/artifactory/repo/ is a virtual repositories that proxy all external repositories

 

Eclipse

Use SolarJoomla (hopefully to be distributed this week) to have a running Eclipse, PDT, Maven 4 PHP environment, Mylyn, TeamCity in no time

Lets build!

First I create a new Maven Project with Archetype “Maven for PHP” “PHP5 libraries”

In TeamCity I did create a new project “Joomla 15 components plugins and modules” and a new Build “MyGuestbook”.

teamcity.maven4php.myguestbook

The first build failed with

[INFO]  PHP Warning: require_once(PHPUnit/TextUI/TestRunner.php): failed to open stream: Operation not permitted

This is because of my PHP security restrictions, I only allow file to be opened from /home/teamcity/

So I just add

/home/teamcity/TeamCity/buildAgent/ to my open_basedir in my php.ini

; open_basedir, if set, limits all file operations to the defined directory
; and below.  This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
open_basedir = /srv/www/vhosts:/tmp:/home/teamcity/TeamCity/buildAgent/

To be continued

So long an empty PHP project is building successfully, tomorrow I will try to make a REAL Joomla! component build there!

As soon as It works, and all my Joomla! components are running in TeamCity, I will try to achieve the same goal in Bamboo, why? because it is simply . . .fun!

Links

You might also like:
Failed opening required PHPUnit/TextUI/TestRunner.php in Mav
1202 days ago
Failed opening required PHPUnit/TextUI/TestRunner.php in Mav
This issue has turn me upside down a long time. In fact in the official Google Group http://groups
Installing Subversion on OpenSuse and Plesk 9
1479 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 chang
When Joomla! meet Maven for PHP
1493 days ago
When Joomla! meet Maven for PHP
  I will quickly describe in this post how you can code your component/plugins/modules agai
My 2 first Joomla! component in continuous build
1494 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/
default thumbnail image alt
1581 days ago
Status of the ContinuousBuild4Joomla framework
I put some effort the last few days in this new framework. Done: I did document some part of it
Installing PHPUnit / Selenium in XAMPP
1606 days ago
Installing PHPUnit / Selenium in XAMPP
    A small how to install PHPUnit via PEAR
blog comments powered by Disqus

Donations

Thank You for supporting my work