dubpub / robo-reset
A trait to reset RoboFile.
Requires (Dev)
- codegyre/robo: *
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-11-23 19:53:38 UTC
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(); } }