You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.md
+37-16Lines changed: 37 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,7 @@ Got a PHP project? Heard of Grunt and Gulp but don't use NodeJS? Task is a pure
20
20
21
21
Ask us anything on Twitter at [@taskphp](https://twitter.com/taskphp).
22
22
23
-
Example
24
-
=======
23
+
# Example
25
24
26
25
```php
27
26
<?php
@@ -68,8 +67,7 @@ $project->addTask('css.watch', ['watch', function ($watch) {
68
67
return $project;
69
68
```
70
69
71
-
Installation
72
-
============
70
+
# Installation
73
71
74
72
Add to your `composer.json`:
75
73
@@ -83,8 +81,36 @@ Add to your `composer.json`:
83
81
84
82
This will allow you to instantiate a `Task\Project`. To run tasks from the command line, install [task/cli](https://github.com/taskphp/cli). You should probably do this now!
85
83
86
-
Usage
87
-
=====
84
+
There are 3 options for installation:
85
+
86
+
## #1 Composer global (recommended)
87
+
```bash
88
+
$> composer global require task/cli ~0.2
89
+
```
90
+
If you haven't installed anything this way before you'll need to update your `PATH`:
The only requirements are that you implement a `Taskfile` that returns a `Task\Project`:
90
116
@@ -149,8 +175,7 @@ $> task greet
149
175
Hello, World!
150
176
```
151
177
152
-
Plugins
153
-
=======
178
+
# Plugins
154
179
155
180
Plugins are where the real work gets done.
156
181
@@ -202,23 +227,19 @@ mbfisher
202
227
203
228
This is a totally pointless example but it demonstrates some core concepts.
204
229
205
-
DI
206
-
--
230
+
## DI
207
231
208
232
Dependency injection is used to setup plugins and inject them into tasks. `Project::inject` allows you to fill a `Pimple` container up with anything you like.
209
233
210
-
Injection
211
-
---------
234
+
## Injection
212
235
213
236
Plugins are injected into tasks using `Task\Injector`. Instead of a `Closure`, pass `Project::addTask` an array with your task as the last element. The preceding elements should be IDs stored in the container; they will be retrieved and passed as arguments to the task.
214
237
215
-
Streams
216
-
-------
238
+
## Streams
217
239
218
240
Plugins are encouraged to use NodeJS-style streams for handling data flows. `Task\Plugin\Stream\ReadableInterface` provides `read` and `pipe` methods, `Task\Plugin\Stream\WritableInterface` provides a `write` method. In the example above `ProcessPlugin::build` returns a `Task\Plugin\Process\ProcessBuilder`, which implements `ReadableInterface`, allowing us to `pipe` a `Task\Plugin\Console\Output\Output` instance to it, which implements `WritableInterface`.
219
241
220
-
Discussion
221
-
==========
242
+
## Discussion
222
243
223
244
* See [nikic's article on PHP over XML](https://nikic.github.io/2012/07/09/A-plea-for-less-XML-configuration-files.html) for a great argument for using pure PHP for configuration.
0 commit comments