PHPackages                             jaz303/phake - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. jaz303/phake

ActiveLibrary[CLI &amp; Console](/categories/cli)

jaz303/phake
============

A wee clone of Ruby's rake for PHP 5.3. Uses closures for ultimate coolness.

v0.6.0(12y ago)362209.9k↓14.2%26[1 issues](https://github.com/jaz303/phake/issues)[8 PRs](https://github.com/jaz303/phake/pulls)7MITPHPPHP &gt;=5.3.0

Since May 27Pushed 3y ago17 watchersCompare

[ Source](https://github.com/jaz303/phake)[ Packagist](https://packagist.org/packages/jaz303/phake)[ Docs](http://github.com/jaz303/phake)[ RSS](/packages/jaz303-phake/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (7)

phake - Rake/Make for PHP 5.3 [![Build Status](https://camo.githubusercontent.com/a01a6efe008a1b0ee7ba9b7f792d41fae086a54b8ee6cbdafdc0669aa4583f60/68747470733a2f2f7472617669732d63692e6f72672f6a617a3330332f7068616b652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/jaz303/phake)
=================================================================================================================================================================================================================================================================================================

[](#phake---rakemake-for-php-53-)

© 2010 Jason Frame \[  / [@jaz303](http://twitter.com/jaz303) \]
Released under the MIT License.

A wee clone of Ruby's `rake` for PHP 5.3. Uses closures for ultimate coolness.

Questions abut `phake`? Come and chat in `#phake` on Freenode!

Usage
-----

[](#usage)

- Download
- Create a `Phakefile` in the current directory or a parent directory
- Invoke `./phake task:name` to invoke task or `./phake -T` to list defined tasks

Defining Tasks
--------------

[](#defining-tasks)

Define tasks like this:

```
task('dependency1', function() {
    echo "i will run first!\n";
});

task('dependency2', function() {
    echo "i will run second!\n";
});

task('task_name', 'dependency1', 'dependency2', function() {
    echo "i will run last!\n";
});

```

This task would be invoked from the command line by `./phake task_name`

Task bodies are optional if you want to create some sort of "super-task" that just invokes a bunch of others:

```
task('foo', 'dep1', 'dep2');

```

And multiple bodies can be added to tasks, all of which will be executed when the task is invoked:

```
task('foo', function() { echo "task work item 1\n"; });
task('foo', function() { echo "task work item 2\n"; });

```

Grouping Tasks
--------------

[](#grouping-tasks)

Like Rake, we can group tasks:

```
group('db', function() {
    task('init', function() {
        echo "i'm initialising the database\n";
    });
});

```

This would be invoked by `./phake db:init`

Describing Tasks
----------------

[](#describing-tasks)

Call `desc()` immediately before defining a task to set its description:

```
desc("Initialises the database");
task('db_init', function() { echo "oh hai it's a database\n"; });

```

Output from `./phake -T`:

```
db_init    Initialises the database

```

After/Before Blocks
-------------------

[](#afterbefore-blocks)

Sometimes you may want to specify that some code should run before or after a task (distinct from dependencies), a bit like Capistrano. Phake supports this:

```
before('foo', function() { ... });
after('baz:bar', function() { ... });

```

Task Arguments
--------------

[](#task-arguments)

Phake allows arguments to specified on the command line:

```
# Execute task `quux` with the given args
./phake quux name=Jason city=Glasgow

```

This format must be matched exactly; do not put spaces between `=` and the argument name/value. If you need to put spaces in the argument value, place the entire assignment in quotes.

Arguments are made available to tasks by the application object's `ArrayAccess` implementation:

```
task('task_with_args', function($app) {
    $name = $app['name'];
    $city = $app['city'];
    // do some stuff...
});

```

Aborting Execution
------------------

[](#aborting-execution)

To abort execution of a task sequence, simply throw an exception.

```
desc('Demonstrate failure');
task('fail', function() {
    throw new Exception;
});

```

Running `phake fail` will yield:

```
- jason@disco phake % ./bin/phake fail
(in /Users/jason/dev/projects/phake)
aborted!
Exception

(See full trace by running task with --trace)

```

A Somewhat More Complete Example
--------------------------------

[](#a-somewhat-more-complete-example)

This is what a complete `Phakefile` might look like. It also highlights some of the more complex name resolution issues arising when dealing with groups.

```

```

Here's the output from `./phake` (implied task to run is `default`):

```
jason@ratchet phake [master*] $ ./phake
(in /Users/jason/dev/projects/phake)
I am the outer environment. I should run first.
I am the inner environment. I should run second.
I am initialising the database...
Running unit tests...
Running a second batch of unit tests...
All tests complete! ()

```

And the corresponding output from `phake -T`:

```
jason@ratchet phake [master*] $ ./phake -T
(in /Users/jason/dev/projects/phake)
database        Initialises the database connection
environment     Load the application environment
test:all:run    Run absolutely every test everywhere!
test:units      Run the unit tests

```

Bash Autocompletion
-------------------

[](#bash-autocompletion)

Bashkim Isai has created [`phake-autocomplete`](https://github.com/bashaus/phake-autocomplete), a bash-completion script for phake task names.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~87 days

Total

4

Last Release

4477d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ba0cb0644325329acbecb3ca33c5175f9c90e97409f2e2bdc90f943aa969b8c?d=identicon)[jaz303](/maintainers/jaz303)

---

Top Contributors

[![clue](https://avatars.githubusercontent.com/u/776829?v=4)](https://github.com/clue "clue (24 commits)")[![jaz303](https://avatars.githubusercontent.com/u/3216?v=4)](https://github.com/jaz303 "jaz303 (20 commits)")[![trq](https://avatars.githubusercontent.com/u/32683?v=4)](https://github.com/trq "trq (9 commits)")[![mekras](https://avatars.githubusercontent.com/u/192067?v=4)](https://github.com/mekras "mekras (2 commits)")[![denzel-morris](https://avatars.githubusercontent.com/u/1693912?v=4)](https://github.com/denzel-morris "denzel-morris (2 commits)")[![tamagokun](https://avatars.githubusercontent.com/u/487333?v=4)](https://github.com/tamagokun "tamagokun (2 commits)")[![swichers](https://avatars.githubusercontent.com/u/5890607?v=4)](https://github.com/swichers "swichers (1 commits)")[![mamchenkov](https://avatars.githubusercontent.com/u/437928?v=4)](https://github.com/mamchenkov "mamchenkov (1 commits)")[![check002](https://avatars.githubusercontent.com/u/483587?v=4)](https://github.com/check002 "check002 (1 commits)")[![kpitn](https://avatars.githubusercontent.com/u/41059?v=4)](https://github.com/kpitn "kpitn (1 commits)")[![benatkin](https://avatars.githubusercontent.com/u/4126?v=4)](https://github.com/benatkin "benatkin (1 commits)")[![mhumpula](https://avatars.githubusercontent.com/u/40766419?v=4)](https://github.com/mhumpula "mhumpula (1 commits)")[![miezuit](https://avatars.githubusercontent.com/u/1755671?v=4)](https://github.com/miezuit "miezuit (1 commits)")

---

Tags

cliautomationTasks

### Embed Badge

![Health badge](/badges/jaz303-phake/health.svg)

```
[![Health](https://phpackages.com/badges/jaz303-phake/health.svg)](https://phpackages.com/packages/jaz303-phake)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[nategood/commando

PHP CLI Commando Style

8123.3M38](/packages/nategood-commando)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
