consolidation/robo
Composer 安装命令:
composer require consolidation/robo
包简介
Modern task runner
README 文档
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
| Branch | Support Level | Symfony | League Container | psr/log | PHP Versions |
|---|---|---|---|---|---|
| 5.x | Stable | 6 - 7 | 3 | 2 - 3 | 8.2 - 8.3 |
| 4.x | Stable | 6 | 3 | 2 - 3 | 8.0 - 8.3 |
| 3.x | Not supported | 4 - 6 | 3 | 1 - 2 | 7.1 - 8.1 |
| 2.x | Not supported | 4 - 5 | 2 | 1 - 2 | 7.1 - 7.4 |
| 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
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/roboto 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.
License
consolidation/robo 适用场景与选型建议
consolidation/robo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65.91M 次下载、GitHub Stars 达 2.71k, 最近一次更新时间为 2016 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 consolidation/robo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 consolidation/robo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 65.91M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2722
- 点击次数: 26
- 依赖项目数: 442
- 推荐数: 5
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-01