Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

rchouinard/phing-tasks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Custom Phing Tasks

This project contains a collection of custom tasks and additions to the Phing build tool for PHP.

LESS Compiler Task

This task utilizes the lessphp library by leafo to compile source files written in LESS syntax into valid CSS. Usage is very easy. Assuming the task files are unpackaged to rych/tasks:

<taskdef name="lessc" classname="rych.tasks.LessCompilerTask" />
<target name="compile-less" description="Compile LESS to CSS">
    <lessc targetdir="path/to/published/css">
        <fileset dir="path/to/less/sources">
            <include name="*.less" />
        </fileset>
    </lessc>
</target>

This block will define the lessc task using the custom task definition, and then define a target to compile all .less files in path/to/less/sources to .css files in path/to/published/css.

Because this task uses a bundled PHP port of the LESS engine, there is no need to have the LESS Ruby gem, or even Ruby, installed on the build machine. More information abot the bundled library, including potential differences between the PHP and Ruby versions, can be found here: http://leafo.net/lessphp/docs/

Task Attributes

Required

  • targetdir - Specifies the directory path for output files.

Optional

There are no optional attributes for this task.

Manifest File Task

A manifest file is simply a text file which contains a listing of files and their hash values. The ManifestFileTask is used to generate and/or verify such a file. This can be useful in ensuring the integrity of your project files.

Phing ships with an undocumented ManifestTask, although I was unsuccessful in getting it to work at all. To avoid conflicts, I've named this one ManifestFileTask instead.

Usage example:

<taskdef name="manifestfile" classname="rych.tasks.ManifestFileTask" />
<target name="generate-manifest" description="Generate a manifest file">
    <manifestfile file="Manifest">
        <fileset dir="path/to/source">
            <include name="*.php" />
        </fileset>
    </manifestfile>
</target>
<target name="verify-manifest" description="Verify a manifest file">
    <manifestfile file="Manifest" mode="verify">
        <fileset dir="path/to/source">
            <include name="*.php" />
        </fileset>
    </manifestfile>
</target>

Task Attributes

Required

  • file - Specifies path to the manifest file.

Optional

  • algo - The hashing algorithm which should be used. Any algorithm supported by PHP's hash extension may be used. Defaults to sha256.
  • mode - One of create or verify. Default is create.

YUI Compressor Task

The YUI compressor is a java tool which can minimize CSS and JavaScript files, saving a few extra bytes. In order to use this task, the java executable must be available in the environment PATH.

Version 2.4.2 of the YUI compressor is included, however it is possible to specify an alternate jar file if needed.

Usage is simple:

<taskdef name="yuic" classname="rych.tasks.YuiCompressorTask" />
<target name="minimize-assets" description="Compress CSS and JavaScript">
    <yuic jarpath="jar/yuic.jar" targetdir="path/to/target">
        <fileset dir="path/to/source">
            <include name="*.css" />
            <include name="*.js" />
        </fileset>
    </yuic>
</target>

Task Attributes

Required

  • targetdir - Specifies the directory path for output files.

Optional

  • jarpath - Path to an alternate jar file.

About

A collection of custom Phing tasks I've created.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages