• Stars
    star
    369
  • Rank 115,686 (Top 3 %)
  • Language
    PHP
  • Created almost 15 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A rake/make clone for PHP 5.3

phake - Rake/Make for PHP 5.3 Build Status

© 2010 Jason Frame [ [email protected] / @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

  • 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

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

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

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

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

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

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

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.

<?php
desc('Load the application environment');
task('environment', function() {
    echo "I am the outer environment. I should run first.\n";
});

desc('Initialises the database connection');
task('database', function() {
    echo "I am initialising the database...\n";
});

group('test', function() {

    // 'environment' dependency for this task is resolved locally to
    // task in same group. There is no 'database' task defined in this
    // group so it drops back to a search of the root group.
    desc('Run the unit tests');
    task('units', 'environment', ':environment', 'database', function() {
        echo "Running unit tests...\n";
    });

    // another level of nesting; application object is passed to all
    // executing tasks
    group('all', function() {
        desc('Run absolutely every test everywhere!');
        task('run', 'test:units', function($application) {
            echo "All tests complete! ($application)\n";
        });
    });

});

// duplicate group definitions are merged
group('test', function() {

    // duplicate task definitions are merged
    // (although the first description takes precedence when running with -T)
    desc("You won't see this description");
    task('units', function() {
        echo "Running a second batch of unit tests...\n";
    });

    // use ':environment' to refer to task in root group
    // we currently have no cyclic dependency checking, you have been warned.
    task('environment', ':environment', function() {
        echo "I am the inner environment. I should run second.\n";
    });

});

task('default', 'test:all:run');
?>

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! (<phake\Application>)

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

Bashkim Isai has created phake-autocomplete, a bash-completion script for phake task names.

More Repositories

1

tipsy

Facebook-style tooltips plugin for jQuery
JavaScript
2,020
star
2

jquery-grab-bag

Miscellaneous small jQuery plugins
JavaScript
291
star
3

boxy

General purpose copycat Facebook dialog/overlay
JavaScript
150
star
4

git-clone

Clone a git repository
JavaScript
63
star
5

droppy

Nested drop downs, jQuery styleee
JavaScript
46
star
6

jquery-console

Bookmarklet which adds jQuery to the current page then displays a console for evaluating Javascript expressions
JavaScript
40
star
7

bitcrusher

Bitcrush effect for Web Audio API
JavaScript
35
star
8

JFHotkeyManager

Global hotkey manager for Cocoa
Objective-C
32
star
9

swift-cli

Test CLI/Makefile project using Swift without Apple's SDK
Swift
25
star
10

ztest

small unit testing library for PHP 5.3
PHP
25
star
11

ColorScope.js

Javascript bookmarklet for live, on-page simulation of various forms of color-blindness
JavaScript
25
star
12

audio-buffer-utils

Utility functions for working with Web Audio API Buffers
JavaScript
23
star
13

JFImageSavePanel

NSSavePanel wrapper for image save dialogs, similar to those in Preview.app
Objective-C
23
star
14

taylor

Experimental package manager and build tool for the Swift programming language
JavaScript
22
star
15

spark

Javascript teaching environment; like Processing with a REPL!
JavaScript
20
star
16

php-helpers

A small Rails-inspired library of PHP helper functions. Simple stuff that really should be in core PHP.
PHP
18
star
17

phpx

true mixins, class_eval, macros and other syntax extensions for PHP 5.3
PHP
17
star
18

SerialBuffer

Arduino serial buffer class for reading delimited messages
C++
17
star
19

base-php

General purpose PHP class library
PHP
13
star
20

spinup

Development process runner: simple, flexible, fast. Unix-friendly!
JavaScript
13
star
21

eyeball

CLI utility for time-dependent colorization of terminal output
JavaScript
12
star
22

SDL2.swift

SDL2 bindings for Swift
Swift
11
star
23

stm32f746g-discovery-gcc

STM32746G-DISCOVERY platform - GCC Makefile project templates and experiments
C
11
star
24

php-lifestream

A simple, efficient lifestream aggregator for PHP
PHP
11
star
25

dart-playground

Just playing about with Dart
10
star
26

template-anything

Turn any git repository into a project template!
JavaScript
10
star
27

clicky

Ruby API client for Clicky web analytics service
Ruby
10
star
28

zing

PHP view-controller framework for PHP 5.3
PHP
10
star
29

gapbuffer

Gap buffer implementation
JavaScript
8
star
30

jquery-lavalamp

Rewrite of the original jQuery LavaLamp plugin
JavaScript
8
star
31

twitty.js

An unsophisticated Twitter timeline client, for browsers (OBSOLETE)
JavaScript
8
star
32

site-skel

Generate skeleton websites from the CLI based on predefined templates and variants
JavaScript
7
star
33

hudkit.js

Javascript UI library
JavaScript
7
star
34

oskar

Lightweight on-screen keyboard
JavaScript
7
star
35

codshit

a ruby dsl for generating natural language
Ruby
6
star
36

rif

Ruby DSL + game runner for making interactive fiction
Ruby
6
star
37

midi-keys

Map MIDI note names => key numbers
JavaScript
6
star
38

xmodem

Java XMODEM client
Java
6
star
39

promise-debounce

Debounce any promise-returning function so that at any instant only one call is pending
JavaScript
5
star
40

drag-queen

Sortable tree widget for jQuery
JavaScript
5
star
41

style-tag

Programatically create <style> elements in the browser
JavaScript
5
star
42

map-range

Simple function domain/range conversion
JavaScript
4
star
43

find-globals

Walk an Esprima-generated AST and identify global symbols
JavaScript
4
star
44

jester

Simple browser-based curly-brace programming language designed for teaching with bytecode VM + green threads
JavaScript
4
star
45

jquery-widgets

Mini-framework for creating jQuery 'widgets'... let's see where this goes...
JavaScript
4
star
46

skelecaster

Send Kinect skeleton data over the network with UDP
C#
4
star
47

dotfiles

Finally moving my dotfiles from svn to git
Vim Script
4
star
48

CSDL2.swift

SDL2 modulemap
Swift
4
star
49

tiny_bootloader

Tiny bootloader for embedded devices, optimised for ease of porting
C
4
star
50

VideoBooth

a Cocoa + Arduino powered push-to-record video booth app
Objective-C
4
star
51

sexy-tabs

jQuery tab transition effect, similar to OS X pref panes
JavaScript
4
star
52

lighty

Launch/wrapper script for lighttpd; a generic "script/server". Currently useful for testing PHP apps against multiple PHP versions, but easily extensible.
Ruby
4
star
53

trigger.js

Tiny signals/slots implementation for JS supporting event dispatch, filtering and pattern-matching
JavaScript
3
star
54

sane-xml

An enjoyable XML parsing experience for Java. A thin, recursive-descent flavoured wrapper around javax.xml.stream.XMLEventReader [now maintained as part of `jazlib.jar`].
Java
3
star
55

asset-warp

Rack middleware for performing JIT image manipulation
Ruby
3
star
56

config.c

Configuration language for C, inspired by nginx config syntax.
C
3
star
57

edge

A CMS for Rails 3.1
Ruby
3
star
58

easiness

Single argument easing functions
JavaScript
3
star
59

echo-chamber

"terminal" widget built with HTML/CSS/JS
JavaScript
3
star
60

read_only_model

Rails plugin allowing ActiveRecord models to be made read-only
Ruby
3
star
61

base-jump

Simple PHP application framework targeting PHP 5.3
JavaScript
3
star
62

hudkit-ace-editor

3
star
63

spitfire

experimental ActiveRecord-style ORM/code generator for PHP
PHP
3
star
64

hotkeys

A hotkey manager that uses event capturing exclusively. IE9+ only.
JavaScript
3
star
65

ruby-snom-addressbook-exporter

Ruby script for exporting your OS X Address Book in a format suitable for import into Snom VOIP phones
3
star
66

fb-canvas-app-skel

A skeleton Facebook canvas app for PHP 5.3
PHP
3
star
67

static-ish

static-ish is a plain text content library for PHP comprising a simple blog engine and support for pages composed of metadata and a list typed blocks.
PHP
3
star
68

basica

Web-embeddable BASIC interpreter, modeled on Locomotive BASIC
JavaScript
3
star
69

swipe-panel

JavaScript
2
star
70

midi-message

Helper functions for generating MIDI messages
JavaScript
2
star
71

little-fat-objects

Schema-free, indexed object model riding on PHP 5.3 and MySQL
PHP
2
star
72

AppleScriptObjCExample

Demonstrates integrating AppleScriptObjC with a standard Cocoa project
Objective-C
2
star
73

superload

PHP class that trawls multiple paths for classes/interfaces and generates a mapping suitable for use in an autoloader
PHP
2
star
74

algorithms

A bunch of algorithms
Ruby
2
star
75

xson

eXtended Serialized Object Notation
JavaScript
2
star
76

node-sdl2-bindings

Work in progress SDL2 bindings for node 7
C++
2
star
77

makitzo

Ruby deployment tool
Ruby
2
star
78

scrap

random assorted code bits and bobs
JavaScript
2
star
79

freefall

Ruby on Rails CMS
JavaScript
2
star
80

interaction-timeout

Trigger a timeout when user has not interacted with document for a period of time
JavaScript
2
star
81

domutil

Simple DOM utilities, framework-free
JavaScript
2
star
82

oboe

Toy operating system targeting ARM Cortex-A8. Status: non-functional
C
2
star
83

z80

Z80 emulator
JavaScript
2
star
84

modlog

Golang module-oriented logger, built on zerolog
Go
2
star
85

buffer.c

dead simple buffer for C
C
2
star
86

sexp-stream

Streaming s-expression parser
2
star
87

min-heap

a min-heap
JavaScript
2
star
88

coursework

Coursework for Udacity and MITx, and exercises from various textbooks
Racket
2
star
89

node-lemur

OS X MIDI playback engine for node.js based on Core MIDI
C++
2
star
90

css-builder

Generate CSS in Javascript! No preprocessing!
JavaScript
2
star
91

Spline

creative coding for Swift
Swift
2
star
92

dom-q

DOM batching library
JavaScript
2
star
93

traitor

Traits library
JavaScript
2
star
94

Cairo.swift

Cairo wrapper for Swift
Swift
2
star
95

slowpoke

Detect slow-running loops and abort after a user-defined timeout
JavaScript
2
star
96

a-language

a programming language.
C
2
star
97

loupe

Cocoa-inspired runloop for C
C
2
star
98

node-octree

Octree
JavaScript
2
star
99

autotable

Rails plugin to auto-generate Bootstrap-compliant HTML tables from model collections
Ruby
2
star
100

DemoBox

Simple Flash sandbox for experimenting with game development techniques
ActionScript
2
star