dubpub/robo-reset
Composer 安装命令:
composer require dubpub/robo-reset
包简介
A trait to reset RoboFile.
README 文档
README
#Dubpub: RoboReset
dubpub/robo-reset is an extension for codegyro/robo package. It allows you to restart your robo process.
####Contents
You can install dubpub/robo-reset using composer:
"require": { "dubpub/robo-reset": "dev-master" }
or from shell
composer require dubpub/robo-reset
##Usage
You can use dubpub/robo-reset either from trait, provided by package Dubpub\RoboReset\RoboResetTrait:
<?php // file - ./RoboFile.php include_once 'vendor/autoload.php' class RoboFile extends \Robo\Tasks { use Dubpub\RoboReset\RoboResetTrait; }
Or you can use dubpub/robo-reset by extending \Dubpub\RoboReset\RoboRestartable, that extends \Robo\Tasks:
<?php // file - ./RoboFile.php include_once 'vendor/autoload.php' class RoboFile extends \Dubpub\RoboReset\RoboRestartable { }
##Examples
The most simple example of usage is monitoring your composer.json changes - if your composer.json file was changed, you need to dump autoloader and restart your RoboFile with new autoloader:
<?php // file - ./RoboFile.php include_once 'vendor/autoload.php' class RoboFile extends \Robo\Tasks { use Dubpub\RoboReset\RoboResetTrait; public function watchComposer() { $this->taskWatch('composer.json', function () { if ($this->taskComposerDumpAutoload()->run()->wasSuccessful()) { /** * Reset robo and output reason-message(optional) **/ $this->resetRobo('Dumped autoloader'); } })->run(); } }
Or you could restart your RoboFile each time it gets modified as well:
<?php // file - ./RoboFile.php include_once 'vendor/autoload.php'; class RoboFile extends \Robo\Tasks { use Dubpub\RoboReset\RoboResetTrait; public function watch() { /** * This method binds a listener on RoboFile. * If RoboFile was modified and it's code passes * standart php lint checks the robo process will be * restarted. * * Method returns an instance of \Robo\Task\Base\Watch * * @var \Robo\Task\Base\Watch $taskWatch */ $taskWatch = $this->restartOnRoboChange(); $taskWatch->monitor(['composer.json'], function () { if ($this->taskComposerDumpAutoload()->run()->wasSuccessful()) { /** * Reset robo and output reason-message(optional) **/ $this->resetRobo('Dumped autoloader'); } }); $taskWatch->run(); } }
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-10-05