2017 © Pedro Peláez

library robo

Modern task runner



Modern task runner

  • Saturday, July 28, 2018
  • by greg.1.anderson
  • Repository
  • 106 Watchers
  • 2077 Stars
  • 1,718,008 Installations
  • PHP
  • 231 Dependents
  • 1 Suggesters
  • 256 Forks
  • 106 Open issues
  • 100 Versions
  • 22 % Grown



Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks:, (*1)

Gitter Latest Stable Version Latest Unstable Version Total Downloads, (*2)

ci scrutinizer codecov license, (*3)

  • writing cross-platform scripts
  • processing assets (less, sass, minification)
  • running tests
  • executing daemons (and workers)
  • watching filesystem changes
  • deployment with sftp/ssh/docker


Branch Support Level Symfony Versions League Container PHP Versions
3.x Stable 4 & 5 ^3 7.1 - 8.0
2.x Not recommended 4 & 5 ^2 7.1 - 7.4
1.x Not recommended 2 - 4 ^2 5.5 - 7.4

The pre-build robo.phar is built with Symfony 5, and requires PHP 7.2+. Robo also works with Symfony 4 and PHP 7.1.3+ if packaged as a library in another application. For Symfony 2 or 3 support, or PHP versions prior to 7.1, please use the Robo 1.x branch., (*4)

All three branches of Robo are currently supported, although the 2.x and 1.x branches receive minimum support. All versions are roughly compatible; the breaking changes introduced at each major version are fairly minor, and typically only affect classes that are not used by most clients., (*5)



Download robo.phar >, (*6)

wget http://robo.li/robo.phar

To install globally put robo.phar in /usr/bin. (/usr/local/bin/ in OSX 10.11+), (*7)

chmod +x robo.phar && sudo mv robo.phar /usr/bin/robo

OSX 10.11+, (*8)

chmod +x robo.phar && sudo mv robo.phar /usr/local/bin/robo

Now you can use it simply via robo., (*9)


  • Run composer require consolidation/robo:^3 # Use ^2 for stable
  • Use vendor/bin/robo to execute Robo tasks.


All tasks are defined as public methods in RoboFile.php. It can be created by running robo init. All protected methods in traits that start with task prefix are tasks and can be configured and executed in your tasks., (*10)


The best way to learn Robo by example is to take a look into its own RoboFile or RoboFile of Codeception project. There are also some basic example commands in examples/RoboFile.php., (*11)

Here are some snippets from them:, (*12)

Run acceptance test with local server and selenium server started., (*13)

``` php <?php, (*14)

use Robo\Symfony\ConsoleIO;, (*15)

class RoboFile extends \Robo\Tasks {, (*16)

function testAcceptance(ConsoleIO $io, $seleniumPath = '~/selenium-server-standalone-2.39.0.jar')
   // launches PHP server on port 8000 for web dir
   // server will be executed in background and stopped in the end

   // running Selenium server in background
   $this->collectionBuilder($io)->taskExec('java -jar ' . $seleniumPath)

   // loading Symfony Command and running with passed argument
   $this->collectionBuilder($io)->taskSymfonyCommand(new \Codeception\Command\Run('run'))

}, (*17)

If you execute `robo` you will see this task added to list of available task with name: `test:acceptance`. To execute it you should run `robo test:acceptance`. You may change path to selenium server by passing new path as a argument:

robo test:acceptance "C:\Downloads\selenium.jar", (*18)

Using `watch` task so you can use it for running tests or building assets. ``` php <?php class RoboFile extends \Robo\Tasks { function watchComposer(ConsoleIO $io) { // when composer.json changes `composer update` will be executed $this->collectionBuilder($io)->taskWatch()->monitor('composer.json', function() { $this->collectionBuilder($io)->taskComposerUpdate()->run(); })->run(); } }

Cleaning logs and cache, (*19)

``` php <?php class RoboFile extends \Robo\Tasks { public function clean(ConsoleIO $io) { $this->collectionBuilder($io)->taskCleanDir([ 'app/cache', 'app/logs' ])->run();, (*20)


}, (*21)

This task cleans `app/cache` and `app/logs` dirs (ignoring .gitignore and .gitkeep files) Can be executed by running:

robo clean, (*22)

---- Creating Phar archive ``` php function buildPhar(collectionBuilder $io) { $files = Finder::create()->ignoreVCS(true)->files()->name('*.php')->in(__DIR__); $packer = $this->collectionBuilder($io)->taskPackPhar('robo.phar'); foreach ($files as $file) { $packer->addFile($file->getRelativePathname(), $file->getRealPath()); } $packer->addFile('robo','robo') ->executable('robo') ->run(); }

We need more tasks!

Create your own tasks and send them as Pull Requests or create packages with "type": "robo-tasks" in composer.json on Packagist., (*23)


Follow @robo_php for updates., (*24)

Brought to you by Consolidation Team and our awesome contributors., (*25)


MIT, (*26)

The Versions

29/06 2017