taskman: yet another Ant alternative

I created a small PHP library taskman for writing project related tasks in a similar with Ant and rake fashion.

There is a lib-taskman project on the google code hosting where you can find the full documentation, sources and latest releases.

It’s probably not that elegant as rake but if you want to stick to PHP and have Ant-alike functionality without any XML programming then taskman may turn out to be handy. taskman is very simple to use, it requires only one include, all its code resides in one PHP file, and it has no external dependencies.

Here is the simplest usage example. Download and unpack the archive. Put taskman.inc.php to some place where you can include it from(I personally tend to bundle this script with every project). Create a task.php script with the following contents:

function task_hello()
  echo "Hello\n";
function task_comma()
  echo ",\n";
 * @deps comma
function task_world()
  echo "World\n";
 * @deps hello,world
function task_say($args = array())
    echo $args[0] . "\n";

You can run this script now in the command line as follows:

>php task.php say Whatever
************************ Running task 'hello' ************************
************************* 'hello' done (0 sec.)*************************
************************ Running task 'comma' ************************
************************* 'comma' done (0 sec.)*************************
************************ Running task 'world' ************************
************************* 'world' done (0 sec.)*************************
************************ Running task 'say' ************************
************************* 'say' done (0 sec.)*************************
************************ All done (0 sec.)************************

You might be wondering what these “project related tasks” are. There can be lot of them: build the sources, bootstrap database, auto-generate code, migrate database schema, deploy project onto remote servers, etc. Maintenance of such tasks can become pretty tedious at some moment. Furthermore, some tasks may depend on other task, e.g. you can not build the sources without running code auto-generation task first.

P.S. Looks like there is a similar PHP solution called pake. The biggest difference between taskman and pake is the way tasks are specified. In case of taskman one has to prefix task functions with task_ keyword while in pake one has to register tasks explicitly using pake_task(..) function. Furthermore, in taskman one attaches task meta information using a PHPDoc block while in pake one should use separate functions, e.g. pake_desc(..).

P.P.S As David noted in comments there is also a Phake project which has, I believe, the strongest resemblance with rake thanks to new PHP-5.3 only features(e.g closures). Some of its ideas I’m going to borrow for taskman2 which will be PHP-5.3 only as well.

6 Responses to “taskman: yet another Ant alternative”

  1. David Says:

    There’s also Phake.

    Haven’t tried any of them yet though. Been using phing for the time being.

  2. Denis Bazhenov Says:

    Why you just don’t use Phing? Is it XML so awful :)

  3. pachanga Says:

    Well, exactly, XML programming is awful :) Besides, as I said, taskman is very simple to use - just one include, no dependencies.

  4. pachanga Says:

    @David, thanks for the link. Phake looks very promising. That’s what probably taskman should have looked like if it used PHP-5.3 features.

  5. Shein Alexey (conf) Says:

    Well done, congrats with publication on PHP Planet :)

  6. My desperate life quest for efficiency » Blog Archive » Cross-platform convenience wrapper around fcsh (for fast incremental Flex builds) Says:

    […] far so good, I implemented the whole project build pipeline using my PHP library taskman(more on it on some other day). By the way, the cool thing about the total control of the build process is the fact I could […]

Leave a Reply