php robo,Robo - 一个 PHP Task runner拥有面向对象的配置

RoboTask

Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks:

68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e73766768747470733a2f2f706f7365722e707567782e6f72672f636f6e736f6c69646174696f6e2f726f626f2f762f737461626c652e706e6768747470733a2f2f706f7365722e707567782e6f72672f636f6e736f6c69646174696f6e2f726f626f2f762f756e737461626c652e706e6768747470733a2f2f706f7365722e707567782e6f72672f636f6e736f6c69646174696f6e2f726f626f2f646f776e6c6f6164732e706e67

68747470733a2f2f7472617669732d63692e6f72672f636f6e736f6c69646174696f6e2f526f626f2e7376673f6272616e63683d6d61696e68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f30383233686e683036707738697234643f7376673d7472756568747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6e736f6c69646174696f6e2f526f626f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3430383637372e737667

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

Symfony Versions

PHP Versions

4 only

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230372d6f6e6c792d393261396564

2, 3 or 4

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230352d737570706f727465642d343038363737

Robo versions 2.x and 1.x are largely compatible; however, Robo 2.x supports fewer versions of PHP and Symfony. This is to make ongoing maintenance easier; Robo 1.x will be supported less and less over time. Projects should update to Robo ^2 if possible.

Installing

Phar

wget http://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 just like robo.

Composer

Run composer require consolidation/robo:~1

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.

class RoboFile extends \Robo\Tasks

{

function testAcceptance($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->taskServer(8000)

->background()

->dir('web')

->run();

// running Selenium server in background

$this->taskExec('java -jar ' . $seleniumPath)

->background()

->run();

// loading Symfony Command and running with passed argument

$this->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.

class RoboFile extends \Robo\Tasks {

function watchComposer()

{

// when composer.json changes `composer update` will be executed

$this->taskWatch()->monitor('composer.json', function() {

$this->taskComposerUpdate()->run();

})->run();

}

}

Cleaning logs and cache

class RoboFile extends \Robo\Tasks

{

public function clean()

{

$this->taskCleanDir([

'app/cache',

'app/logs'

])->run();

$this->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()

{

$files = Finder::create()->ignoreVCS(true)->files()->name('*.php')->in(__DIR__);

$packer = $this->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.

License

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值