1
1
# Phpake
2
2
3
3
Phpake is a make-like utility built for PHP. It is pronounced * fake* because
4
- the second * p* is silent just like the word * elephpant* .
4
+ the second * p* is silent just like the second ` p ` in the word * elephpant* .
5
5
6
- I've always found writing a ` Makefile ` quite challenging because its syntax
7
- is similar to the shell syntax, but it is very different at the same time.
8
- When I'm working on Ruby, I use ` rake ` and it was awesome because it uses
9
- Ruby syntax. But when I work on PHP, I often miss having a similar tool that
6
+ I've always found writing a ` Makefile ` quite challenging because the syntax
7
+ is similar to the shell syntax, but quite different at the same time.
8
+ When I'm working with Ruby, I use ` rake ` and it's awesome because it uses
9
+ Ruby syntax. When I work with PHP, I often miss having a similar tool that
10
10
is easy to install, easy to use, and allows full-fledged PHP syntax. Thus,
11
11
Phpake was born.
12
12
@@ -38,7 +38,7 @@ You should then be able to run it with `composer exec phpake`.
38
38
39
39
## Usage
40
40
41
- To use Phpake, you start by creating a ` Phpakefile ` where you define tasks.
41
+ To use Phpake, start by creating a ` Phpakefile ` to define some tasks.
42
42
Each task is simply a PHP function. You can read more on creating a
43
43
` Phpakefile ` under the [ Phpakefile] ( #Phpakefile ) section.
44
44
@@ -52,9 +52,15 @@ containing a `Phpakefile`.
52
52
53
53
## Phpakefile
54
54
55
- The following subheadings talk about writing tasks in a ` Phpakefile ` . A
56
- Phpake task definition is simply a PHP function (a task callback). Here's
57
- a sample [ Phpakefile] ( Phpakefile ) to inspire you.
55
+ A * Phpakefile* contains definitions of tasks that can be executed by Phpake.
56
+ The following subheadings are about defining such tasks. A Phpake task definition
57
+ is simply a PHP function (a task callback). Here's are some examples:
58
+
59
+ - [ Hello world] ( Phpakefile )
60
+ - [ Input Output] ( examples/input-output.phpakefile )
61
+ - [ Namespaces] ( examples/variadic.phpakefile )
62
+ - [ Variadic arguments] ( examples/variadic.phpakefile )
63
+ - [ Shell commands] ( examples/shell.phpakefile )
58
64
59
65
## Simple tasks
60
66
@@ -70,7 +76,8 @@ function hello_world() {
70
76
}
71
77
```
72
78
73
- This task can then be executed as ` phpake hello-world ` .
79
+ This task can then be executed as ` phpake hello-world ` . You can also organize
80
+ functions with PHP namespaces.
74
81
75
82
## Regular Parameters
76
83
@@ -83,16 +90,15 @@ function hello_human($fname, $lname = NULL) {
83
90
}
84
91
```
85
92
86
- Since ` $lname ` has a default value, it is treated as an optional argument. So,
87
- this task can be executed as ` phpake Niki ` or ` phpake Niki Martin ` .
93
+ Since ` $lname ` has a default value, it is treated as an optional argument.
88
94
89
95
## Special parameters
90
96
91
- Phpake is build with [ Symfony Console] ( https://symfony.com/doc/current/components/console.html ) ,
97
+ Phpake is built with [ Symfony Console] ( https://symfony.com/doc/current/components/console.html ) ,
92
98
which provides certain special parameters that can help you enrich your
93
- application even further. If your task has a parameter with one of these
94
- special names, it will behave specially. You can read more about some of these
95
- objects in the Symfony Console documentation.
99
+ application even further. If your task has a parameter with one of these
100
+ special names, it will behave specially. For more info on these objects,
101
+ please refer to the Symfony Console documentation.
96
102
97
103
### $input
98
104
@@ -116,9 +122,12 @@ The text included in `<info></info>` will appear in color.
116
122
Name of the Symfony Console command that is being executed. It looks like the
117
123
task function name with some minor differences.
118
124
125
+ - For a ` function hello_world() ` the command becomes ` hello-world `
126
+ - If defined in a namespace, it becomes ` namespace:hello-world ` .
127
+
119
128
### $rest
120
129
121
- There are often tasks that can accept an unlimited number of arguments. These
130
+ Often there are tasks that can accept an unlimited number of arguments. These
122
131
can be handled with a ` $rest ` parameter. It ** must be** defined as the last
123
132
argument to your function.
124
133
0 commit comments