2017 © Pedro Peláez
 

library robo-reset

A trait to reset RoboFile.

image

dubpub/robo-reset

A trait to reset RoboFile.

  • Monday, October 5, 2015
  • by dubpub
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Dubpub: RoboReset

Build Status Code Climate Coverage Status, (*1)

dubpub/robo-reset is an extension for codegyro/robo package. It allows you to restart your robo process., (*2)

Contents

Installing

You can install dubpub/robo-reset using composer:, (*3)

    "require": {
        "dubpub/robo-reset": "dev-master"
    }

or from shell, (*4)

composer require dubpub/robo-reset

Usage

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
{

}

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:, (*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();
    }
}

The Versions

05/10 2015

dev-master

9999999-dev

A trait to reset RoboFile.

  Sources   Download

The Development Requires

05/10 2015

dev-dev

dev-dev

A trait to reset RoboFile.

  Sources   Download

The Development Requires