We will start creating a rather simple task which basically does nothing more than echo a message to the screen. See [below] for the source code and the following [below] for the XML definition that is used for this task.
<?php require_once "phing/Task.php"; class MyEchoTask extends Task { /** * The message passed in the buildfile. */ private $message = null; /** * The setter for the attribute "message" */ public function setMessage($str) { $this->message = $str; } /** * The init method: Do init steps. */ public function init() { // nothing to do here } /** * The main entry point method. */ public function main() { print($this->message); } } ?>
This code contains a rather simple, but complete Phing task. It is assumed that
the file is named MyEchoTask.php
and placed in
classes/phing/tasks/my
directory. We'll explain the source
code in detail shortly. But first we'd like to discuss how we should register the
task to Phing so that it can be executed during the build process.