bda0b728edc9ca544a585cd4ba3b550f59ff3466
[yaffs-website] / vendor / consolidation / robo / README.md
1 # RoboTask
2
3 **Modern and simple PHP task runner** inspired by Gulp and Rake aimed to automate common tasks:
4
5 [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/consolidation-org/Robo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 
6 [![Latest Stable Version](https://poser.pugx.org/consolidation/robo/v/stable.png)](https://packagist.org/packages/consolidation/robo) 
7 [![Latest Unstable Version](https://poser.pugx.org/consolidation/robo/v/unstable.png)](https://packagist.org/packages/consolidation/robo) 
8 [![Total Downloads](https://poser.pugx.org/consolidation/robo/downloads.png)](https://packagist.org/packages/consolidation/robo) 
9 [![PHP 7 ready](http://php7ready.timesplinter.ch/consolidation/Robo/badge.svg)](https://travis-ci.org/consolidation/Robo)
10 [![License](https://poser.pugx.org/consolidation/robo/license.png)](https://www.versioneye.com/user/projects/57c4a6fe968d64004d97620a?child=57c4a6fe968d64004d97620a#tab-licenses)
11
12 [![Build Status](https://travis-ci.org/consolidation/Robo.svg?branch=master)](https://travis-ci.org/consolidation/Robo) 
13 [![Windows CI](https://ci.appveyor.com/api/projects/status/0823hnh06pw8ir4d?svg=true)](https://ci.appveyor.com/project/greg-1-anderson/robo)
14 [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/Robo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/Robo/?branch=master)
15 [![Dependency Status](https://www.versioneye.com/user/projects/57c4a6fe968d64004d97620a/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57c4a6fe968d64004d97620a)
16
17 * writing cross-platform scripts
18 * processing assets (less, sass, minification)
19 * running tests
20 * executing daemons (and workers)
21 * watching filesystem changes
22 * deployment with sftp/ssh/docker
23
24 ## Installing
25
26 ### Phar
27
28 [Download robo.phar >](http://robo.li/robo.phar)
29
30 ```
31 wget http://robo.li/robo.phar
32 ```
33
34 To install globally put `robo.phar` in `/usr/bin`.
35
36 ```
37 chmod +x robo.phar && sudo mv robo.phar /usr/bin/robo
38 ```
39
40 Now you can use it just like `robo`.
41
42 ### Composer
43
44 * Run `composer require consolidation/robo:~1`
45 * Use `vendor/bin/robo` to execute Robo tasks.
46
47 ## Usage
48
49 All tasks are defined as **public methods** in `RoboFile.php`. It can be created by running `robo`.
50 All protected methods in traits that start with `task` prefix are tasks and can be configured and executed in your tasks.
51
52 ## Examples
53
54 The best way to learn Robo by example is to take a look into [its own RoboFile](https://github.com/consolidation-org/Robo/blob/master/RoboFile.php)
55  or [RoboFile of Codeception project](https://github.com/Codeception/Codeception/blob/master/RoboFile.php). There are also some basic example commands in examples/RoboFile.php.
56
57 Here are some snippets from them:
58
59 ---
60
61 Run acceptance test with local server and selenium server started.
62
63
64 ``` php
65 <?php
66 class RoboFile extends \Robo\Tasks
67 {
68
69     function testAcceptance($seleniumPath = '~/selenium-server-standalone-2.39.0.jar')
70     {
71        // launches PHP server on port 8000 for web dir
72        // server will be executed in background and stopped in the end
73        $this->taskServer(8000)
74             ->background()
75             ->dir('web')
76             ->run();
77
78        // running Selenium server in background
79         $this->taskExec('java -jar ' . $seleniumPath)
80             ->background()
81             ->run();
82
83         // loading Symfony Command and running with passed argument
84         $this->taskSymfonyCommand(new \Codeception\Command\Run('run'))
85             ->arg('suite','acceptance')
86             ->run();
87     }
88 }
89 ```
90
91 If you execute `robo` you will see this task added to list of available task with name: `test:acceptance`.
92 To execute it you should run `robo test:acceptance`. You may change path to selenium server by passing new path as a argument:
93
94 ```
95 robo test:acceptance "C:\Downloads\selenium.jar"
96 ```
97
98 Using `watch` task so you can use it for running tests or building assets.
99
100 ``` php
101 <?php
102 class RoboFile extends \Robo\Tasks {
103
104     function watchComposer()
105     {
106         // when composer.json changes `composer update` will be executed
107         $this->taskWatch()->monitor('composer.json', function() {
108             $this->taskComposerUpdate()->run();
109         })->run();
110     }
111 }
112 ```
113
114 ---
115
116 Cleaning logs and cache
117
118 ``` php
119 <?php
120 class RoboFile extends \Robo\Tasks
121 {
122     public function clean()
123     {
124         $this->taskCleanDir([
125             'app/cache',
126             'app/logs'
127         ])->run();
128
129         $this->taskDeleteDir([
130             'web/assets/tmp_uploads',
131         ])->run();
132     }
133 }
134 ```
135
136 This task cleans `app/cache` and `app/logs` dirs (ignoring .gitignore and .gitkeep files)
137 Can be executed by running:
138
139 ```
140 robo clean
141 ```
142
143 ----
144
145 Creating Phar archive
146
147 ``` php
148 function buildPhar()
149 {
150     $files = Finder::create()->ignoreVCS(true)->files()->name('*.php')->in(__DIR__);
151     $packer = $this->taskPackPhar('robo.phar');
152     foreach ($files as $file) {
153         $packer->addFile($file->getRelativePathname(), $file->getRealPath());
154     }
155     $packer->addFile('robo','robo')
156         ->executable('robo')
157         ->run();
158 }
159 ```
160
161 ---
162
163 ## We need more tasks!
164
165 Create your own tasks and send them as Pull Requests or create packages prefixed with `robo-` on Packagist.
166
167 ## Credits
168
169 Follow [@robo_php](http://twitter.com/robo_php) for updates.
170
171 Brought to you by [Consolidation Team](https://github.com/orgs/consolidation/people) and our [awesome contributors](https://github.com/consolidation/Robo/graphs/contributors).
172
173 ## License
174
175 [MIT](https://github.com/consolidation/Robo/blob/master/LICENSE)