pake is not a building tool like make or rake. pake is meant to provide centralized command-line scripts to your PHP 5 projects.
All it requires is a Pakefile, which is a plain PHP, and to use two simple functions: desc (optional) and task.
<?php
desc('clears the cache');
task('clear_cache');
function clear_cache($path=null)
{
}
?>
You can then invoke this task with:
$ pake clear_cache $ pake clear_cache path/to/tmp
You may also specify the function’s name:
<?php
desc('creates cache directory');
task('create_cache', tmp_create_cache);
function tmp_create_cache($path=null)
{
}
?>
You can then invoke these tasks the same way that you invoked clear_cache.
Of course, being some PHP, you may include/require external files from your Pakefile:
<?php include 'tasks/tmp.rake'; include 'tasks/database.rake'; ?>
Any argument passed on the command line will be passed as function arguments to your tasks. Uppercased arguments, like +STEP=2+ will be processed as an environment variable, and will thus set +$_SERVER = 2+.
For instance:
<?php
task('db:migrate', 'db_migrate');
function db_migrate($command)
{
if (!isset($_SERVER['STEP'])) $_SERVER['STEP'] = 1;
}
?>
$ pake db:migrate redo STEP=2
If you are running PHP 5.3, you may use namespaces and closures, leading to some nicer code.
<?php
namespace tmp;
desc('creates tmp subdirectories');
task('tmp:create');
function create()
{
}
desc('clears the cache');
task('tmp:clear', function($path=null)
{
});
?>
You can then invoke those tasks using:
$ pake tmp:create $ pake tmp:clear $ pake tmp:clear path/to/tmp
You may list the avaiable tasks by simple typing pake:
$ pake (in /path/to/myapp) tmp:clear clears the cache tmp:create creates tmp subdirectories
pake provides a very basic Pake_FileUtils class, but nothing as sexy as rake classes (FileList, CLEAN, etc). Hey, patches are welcome :)