We have been busy setting up a continuous integration server at work this week, and I am impressed with the results.
We started by looking at using PHING and Xinc but found with the current setup of our tests and some other bits and pieces weren’t working together nicely. The major stumbling blocks being that PHING does not support running an AllTests.php PHPUnit setup and the lack of documentation for Xinc ( It is just past beta so very understandable ).
So after much tweaking with no success we decided to try Ant + PHPUnderControl + Cruise Control, I was a bit apprehensive about using a Java app as it would be harder to extend. However we found that it did exactly what we needed and works a treat. Now we have a nice new shiny CI Server in our office shouting at us when we break things :)
I was impressed with how nicely Ant was to configure (for win & linux!) and now we have it Updating the local build, Creating the build folders, Compressing the JS/Css, and Running the tests. Sweet :) PHPUnderControl is really cool, I now have nice set of data for all aspects of my project. This includes test results, Code Coverage reports, Coding Standards Compliance, and probably some other stuff I forgot…
Anyway so hopefully I will be posting some stuff on website accessibility soon, I was talking to someone about it today and thought it would be good to blog about....
Posted on 09/05/2008 at 05:15 PM
So a major part of my weblog setup using the core version of Expression Engine was adding a way of tagging my posts. In the end I came up with an extension to add the admin functionality and a plugin to get various data into the frontend.
Creating the extension
Ok before we start you need to make sure that:
- Your MySql server has InnoDb table support
- You are running PHP5 ( seriously you shouldnt be using 4 anymore! )
- You have download Zend Framework and added into your include path
Next lets setup a skeletion structure for the extension. Create a file called ext.kp_tagging.php in the extensions dir.
Posted on 06/05/2008 at 08:47 PM
Hi Just thought I would blog a new phing task I just created that minifies css or javascript using YUI Compressor
This would be placed in build/extended/tasks/kpMinTask.php, also place the yuicompressor in build/tools/yuicompressor.jar
<?php
/**
* Uses the Phing Task
*/
require_once 'phing/Task.php';
/**
* Task to compress files using YUI Compressor.
*
* @author Keith Pope
*/
class kpMinTask extends Task
{
/**
* path to YuiCompressor
*
* @var string
*/
protected $yuiPath;
/**
* the source files
*
* @var FileSet
*/
protected
$filesets = array();
/**
* Whether the build should fail, if
* errors occured
*
* @var boolean
*/
protected $failonerror = false;
/**
* directory to put minified javascript files into
*
* @var string
*/
protected $targetDir;
/**
* sets the path where JSmin can be found
*
* @param string $yuiPath
*/
public function setYuiPath( $yuiPath )
{
$this->yuiPath = $yuiPath;
}
/**
* Nested creator, adds a set of files (nested fileset attribute).
*/
public function createFileSet()
{
$num = array_push( $this->filesets, new FileSet
() );
return $this->filesets[$num - 1];
}
/**
* Whether the build should fail, if an error occured.
*
* @param boolean $value
*/
public function setFailonerror( $value )
{
$this->failonerror = $value;
}
/**
* sets the directory compressor traget dir
*
* @param string $targetDir
*/
public function setTargetDir( $targetDir )
{
$this->targetDir = $targetDir;
}
/**
* The init method: Do init steps.
*/
public function init()
{
return true;
}
/**
* The main entry point method.
*/
public function main()
{
$command = 'java -jar {yuipath} {src} -o {target}';
foreach( $this->filesets as $fs )
{
try
{
$files = $fs->getDirectoryScanner( $this->project )->getIncludedFiles();
$fullPath = realpath( $fs->getDir( $this->project ) );
foreach( $files as $file )
{
$this->log( 'Minifying file ' . $file );
$target = $this->targetDir . '/' . str_replace( $fullPath, '', $file );
{
}
$cmd = str_replace( '{src}', $fullPath . DIRECTORY_SEPARATOR
. $file, $command );
$return = null;
exec( $cmd, $output, $return );
foreach( $output as $line )
{
$this->log( $line, Project::MSG_VERBOSE );
}
if( $return != 0 )
{
throw new BuildException( "Task exited with code $return" );
}
}
}
catch( BuildException $be )
{
// directory doesn't exist or is not readable
if ($this->failonerror)
{
throw $be;
}
else
{
$this->log($be->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
}
}
}
}
}
?>
Then in your phing build.xml
<taskdef name="minify" classname="extended.tasks.kpMinTask" />
<target name="minify-js">
<echo>--------------------------------</echo>
<echo>| Minify javascript to release |</echo>
<echo>--------------------------------</echo>
<minify targetDir="../www/resources/js/min"
yuiPath="tools/yuicompressor.jar">
<fileset dir="../www/resources/js/">
<include name="*.js"/>
</fileset>
</minify>
</target>
<target name="minify-css">
<echo>--------------------------------</echo>
<echo>| Minify CSS to release |</echo>
<echo>--------------------------------</echo>
<minify targetDir="../www/resources/v2_css/min"
yuiPath="tools/yuicompressor.jar">
<fileset dir="../www/resources/v2_css/">
<include name="*.css"/>
</fileset>
</minify>
</target>
Now we can can compress easily by running phing minify-js, sweet...
Posted on 04/05/2008 at 12:08 PM