consolidation / robo
Modern task runner
Installs: 46 832 401
Dependents: 468
Suggesters: 4
Security: 0
Stars: 2 666
Watchers: 82
Forks: 304
Open Issues: 180
Requires
- php: >=8.2
- consolidation/annotated-command: ^4.8.1
- consolidation/config: ^3
- consolidation/log: ^3
- consolidation/output-formatters: ^4.1.2
- league/container: ^3.3.1 || ^4.0
- phpowermove/docblock: ^4.0
- symfony/console: ^6 || ^7
- symfony/event-dispatcher: ^6 || ^7
- symfony/filesystem: ^6 || ^7
- symfony/finder: ^6 || ^7
- symfony/process: ^6 || ^7
- symfony/yaml: ^6 || ^7
Requires (Dev)
- natxet/cssmin: 3.0.4
- patchwork/jsqueeze: ^2
- pear/archive_tar: ^1.4.4
- phpunit/phpunit: ^7.5.20 || ^8 || ^9
- squizlabs/php_codesniffer: ^3.6
- yoast/phpunit-polyfills: ^0.2.0
Suggests
- consolidation/self-update: For self-updating a phar-based app built with Robo
- natxet/cssmin: For minifying CSS files in taskMinify
- patchwork/jsqueeze: For minifying JS files in taskMinify
- pear/archive_tar: Allows tar archives to be created and extracted in taskPack and taskExtract, respectively.
- totten/lurkerlite: For monitoring filesystem changes in taskWatch
Conflicts
- 5.x-dev
- 5.1.0
- 5.0.0
- 4.x-dev
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 4.0.0-alpha1
- 3.x-dev
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0-alpha3
- 3.0.0-alpha2
- 3.0.0-alpha1
- 2.x-dev
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-alpha3
- 2.0.0-alpha2
- 2.0.0-alpha1
- 1.x-dev
- 1.5.0
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.0
- 1.0.0-RC3
- 1.0.0-RC2
- 1.0.0-RC1
- 1.0.0-beta1
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.0
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.0
- 0.2.0
- 0.1.1
- 0.1.0
- dev-larowlan-symfony7
- dev-register-multiple
- dev-robo-register-3.x
- dev-robo-register
- dev-php-8.2-support-3.x
- dev-site
- dev-php8.2-support
- dev-update-dependencies-for-4
- dev-consolidation-log-3
- dev-psr-log-2
- dev-symfony-process-6
- dev-symfony-6
- dev-php-8.1
- dev-homebrew-integration
- dev-robo-1-with-self-update-2
- dev-use-self-update-2.0
- dev-fix-task-pack
- dev-update-dependencies
- dev-prep-for-3.0
- dev-older-process-component
- dev-php-8
- dev-finder5
- dev-use-printoutput
- dev-fix-ignorelist
- dev-capture-exec-output
- dev-pass-io-param
- dev-simplify-init-test-tasks-trait
- dev-save-and-restore-state
- dev-symfony4-lowest
- dev-inject-input-output
- dev-version-bump
- dev-get-command-instance
This package is auto-updated.
Last update: 2024-11-22 13:28:43 UTC
README
Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks:
- writing cross-platform scripts
- processing assets (less, sass, minification)
- running tests
- executing daemons (and workers)
- watching filesystem changes
- deployment with sftp/ssh/docker
Branches
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.
Note also that Robo 5.x removed consolidation/self-update as a direct dependency. You will need to explicitly add it if you are using it to update your application phar.
Installing
Phar
wget https://robo.li/robo.phar
To install globally put robo.phar
in /usr/bin
. (/usr/local/bin/
in OSX 10.11+)
chmod +x robo.phar && sudo mv robo.phar /usr/bin/robo
OSX 10.11+
chmod +x robo.phar && sudo mv robo.phar /usr/local/bin/robo
Now you can use it simply via robo
.
Composer
- Run
composer require consolidation/robo:^4
- Use
vendor/bin/robo
to execute Robo tasks.
Usage
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.
Examples
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
.
Here are some snippets from them:
Run acceptance test with local server and selenium server started.
<?php use Robo\Symfony\ConsoleIO; class RoboFile extends \Robo\Tasks { 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 $this->collectionBuilder($io)->taskServer(8000) ->background() ->dir('web') ->run(); // running Selenium server in background $this->collectionBuilder($io)->taskExec('java -jar ' . $seleniumPath) ->background() ->run(); // loading Symfony Command and running with passed argument $this->collectionBuilder($io)->taskSymfonyCommand(new \Codeception\Command\Run('run')) ->arg('suite','acceptance') ->run(); } }
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"
Using watch
task so you can use it for running tests or building assets.
<?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() use ($io) { $this->collectionBuilder($io)->taskComposerUpdate()->run(); })->run(); } }
Cleaning logs and cache
<?php class RoboFile extends \Robo\Tasks { public function clean(ConsoleIO $io) { $this->collectionBuilder($io)->taskCleanDir([ 'app/cache', 'app/logs' ])->run(); $this->collectionBuilder($io)->taskDeleteDir([ 'web/assets/tmp_uploads', ])->run(); } }
This task cleans app/cache
and app/logs
dirs (ignoring .gitignore and .gitkeep files)
Can be executed by running:
robo clean
Creating Phar archive
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.
Credits
Follow @robo_php for updates.
Brought to you by Consolidation Team and our awesome contributors.