dev-master
9999999-devA trait to reset RoboFile.
The Development Requires
dev-dev
dev-devA trait to reset RoboFile.
The Development Requires
Wallogit.com
2017 © Pedro Peláez
A trait to reset RoboFile.
dubpub/robo-reset is an extension for codegyro/robo package. It allows you to restart your robo process., (*2)
You can install dubpub/robo-reset using composer:, (*3)
"require": {
"dubpub/robo-reset": "dev-master"
}
or from shell, (*4)
composer require dubpub/robo-reset
You can use dubpub/robo-reset either from trait, provided by package Dubpub\RoboReset\RoboResetTrait:, (*5)
<?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:, (*6)
<?php // file - ./RoboFile.php
include_once 'vendor/autoload.php'
class RoboFile extends \Dubpub\RoboReset\RoboRestartable
{
}
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:, (*7)
<?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:, (*8)
<?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();
}
}
A trait to reset RoboFile.
A trait to reset RoboFile.