Giter Site home page Giter Site logo

robo's Introduction

RoboTask

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

Gitter Build Status Latest Stable Version Total Downloads Latest Unstable Version License PHP 7 ready

  • writing cross-platform scripts
  • processing assets (less, sass, minification)
  • running tests
  • executing daemons (and workers)
  • watching filesystem changes
  • deployment with sftp/ssh/docker

Installing

Phar

Download robo.phar >

wget http://robo.li/robo.phar

To install globally put robo.phar in /usr/bin.

chmod +x robo.phar && sudo mv robo.phar /usr/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. 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

Here are some snippets from them:


Run acceptance test with local server and selenium server started.

<?php
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->taskCommand(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 shoud 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.

<?php
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

<?php
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 prefixed with robo- on Packagist.

Credits

Follow @robo_php for updates.

Created by Michael Bodnarchuk @davert.

License

MIT

robo's People

Contributors

davertmik avatar greg-1-anderson avatar boedah avatar jadb avatar rarst avatar burzum avatar jonsa avatar sebsept avatar pscheit avatar pmcjury avatar maxakawizard avatar dustinleblanc avatar schorsch3000 avatar ekho avatar fetchandadd avatar javigomez avatar pfaocle avatar gabor-udvari avatar anvi avatar tspg128 avatar webflo avatar sweetchuck avatar rdeutz avatar raphaelstolt avatar ijackua avatar bkawakami avatar lvancrayelynghe avatar arnaudligny avatar butochnikov avatar raistlin avatar

Watchers

Benjamin Doherty avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.