base on Modern task runner for PHP # RoboTask **Modern and simple PHP task runner** inspired by Gulp and Rake aimed to automate common tasks: [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/consolidation/Robo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Latest Stable Version](https://poser.pugx.org/consolidation/robo/v/stable.png)](https://packagist.org/packages/consolidation/robo) [![Latest Unstable Version](https://poser.pugx.org/consolidation/robo/v/unstable.png)](https://packagist.org/packages/consolidation/robo) [![Total Downloads](https://poser.pugx.org/consolidation/robo/downloads.png)](https://packagist.org/packages/consolidation/robo) [![ci](https://github.com/consolidation/robo/workflows/CI/badge.svg)](https://github.com/consolidation/robo/actions) [![scrutinizer](https://scrutinizer-ci.com/g/consolidation/robo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/robo/?branch=master) [![codecov](https://codecov.io/gh/consolidation/robo/branch/main/graph/badge.svg?token=CAaB7ofhxx)](https://codecov.io/gh/consolidation/robo) [![license](https://poser.pugx.org/consolidation/robo/license)](https://packagist.org/packages/consolidation/robo) * writing cross-platform scripts * processing assets (less, sass, minification) * running tests * executing daemons (and workers) * watching filesystem changes * deployment with sftp/ssh/docker ## Branches | Branch | Support Level | Symfony | League Container | psr/log | PHP Versions | | ------ | ------------- | ------- | ---------------- | ------------ | ------------ | | [5.x](https://github.com/consolidation/robo/tree/5.x) | Stable | 6 - 7 | 3 | 2 - 3 | 8.2 - 8.3 | | [4.x](https://github.com/consolidation/robo/tree/4.x) | Stable | 6 | 3 | 2 - 3 | 8.0 - 8.3 | | [3.x](https://github.com/consolidation/robo/tree/3.x) | Not supported | 4 - 6 | 3 | 1 - 2 | 7.1 - 8.1 | | [2.x](https://github.com/consolidation/robo/tree/2.x) | Not supported | 4 - 5 | 2 | 1 - 2 | 7.1 - 7.4 | | [1.x](https://github.com/consolidation/robo/tree/1.x) | Not supported | 2 - 4 | 2 | 1 - 2 | 5.5 - 7.4 | 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 [Download robo.phar >](https://robo.li/robo.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](https://github.com/consolidation/Robo/blob/2.x/RoboFile.php) or [RoboFile of Codeception project](https://github.com/Codeception/Codeception/blob/2.4/RoboFile.php). 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 <?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 <?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 <?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 ``` 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](https://packagist.org/?type=robo-tasks). ## Credits Follow [@robo_php](https://twitter.com/robo_php) for updates. Brought to you by [Consolidation Team](https://github.com/orgs/consolidation/people) and our [awesome contributors](https://github.com/consolidation/Robo/graphs/contributors). ## License [MIT](https://github.com/consolidation/Robo/blob/3.x/LICENSE) ", Assign "at most 3 tags" to the expected json: {"id":"669","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"