2017 © Pedro Peláez
 

robo-tasks robo-config

CI/developer-friendly configuration processor for Robo.

image

nuvoleweb/robo-config

CI/developer-friendly configuration processor for Robo.

  • Tuesday, January 9, 2018
  • by ademarco
  • Repository
  • 2 Watchers
  • 3 Stars
  • 9,704 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 9 Versions
  • 33 % Grown

The README.md

Robo Config

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Robo Config enables a flexible configuration processing for Robo by providing the following features:, (*2)

  • Define your default configuration in robo.yml.dist and let developers override that locally in their robo.yml.
  • Allow configuration files to use properties defined within the same configuration in a Phing-like fashion.
  • Allow all properties to be overridden on the command line so that they can be tweaked when running continuous integration builds.
  • Access any configuration parameter via $this->config('my.configuration.property);`

Installation

Install with Composer by running:, (*3)

$ composer require nuvoleweb/robo-config

Usage

After installation add the following trait to your RoboFile.php:, (*4)

<?php
class RoboFile extends Robo\Tasks {

  use NuvoleWeb\Robo\Task\Config\loadTasks;

}

For example, consider having the following robo.yml.dist file:, (*5)

site:
  name: "Default site name"
  email: "me@example.com"
  url: "http://localhost"
account:
  name: "admin"
  password: !account.name
  email: !site.email

And the following robo.yml file:, (*6)

site:
  name: "My site name"

When running:, (*7)

./vendor/bin/robo my-command -o "site.url: http://127.0.0.1:8888"

The resulting configuration will be:, (*8)

site:
  name: "My site name"
  email: "me@example.com"
  url: "http://127.0.0.1:8888"
account:
  name: "admin"
  password: "admin"
  email: "me@example.com"

Robo configuration in PHP files

Robo Config exposes three tasks that allow to convert a YAML configuration subset into PHP array. Such array will be then appended, prepended or written down to a PHP destination file as an array., (*9)

This might be useful for applications that have part of their configuration expressed in a PHP file, like Drupal or Silex., (*10)

For example, the following YAML portion:, (*11)

settings:
  config:
    system.logging:
      error_level: verbose
  settings:
    scan_tests: TRUE

Will be converted into:, (*12)

// Start settings processor block.

$config["system.logging"] = array('error_level' => 'verbose');

$settings["scan_tests"] = true;

// End settings processor block.

And added to a PHP file., (*13)

Append task

Given an existing /my/config.php file, by calling:, (*14)

<?php
class RoboFile {

  public function appendTask() {
    $this->taskAppendConfiguration('/my/config.php')->run();  
  }

}    

We will get the following result:, (*15)

<?php

// Content of /my/config.php here...

// Start settings processor block.

$config["system.logging"] = array('error_level' => 'verbose');

$settings["scan_tests"] = true;

// End settings processor block.

Prepend task

Given an existing /my/config.php file, by calling:, (*16)

<?php
class RoboFile {

  public function appendTask() {
    $this->taskPrependConfiguration('/my/config.php')->run();  
  }

}    

We will get the following result:, (*17)

<?php

// Start settings processor block.

$config["system.logging"] = array('error_level' => 'verbose');

$settings["scan_tests"] = true;

// End settings processor block.

// Content of /my/config.php here...

Write task

Given a non-existing /my/config.php file, by calling:, (*18)

<?php
class RoboFile {

  public function appendTask() {
    $this->taskWriteConfiguration('/my/config.php')->run();  
  }

}    

We will get the following result:, (*19)

<?php

// Start settings processor block.

$config["system.logging"] = array('error_level' => 'verbose');

$settings["scan_tests"] = true;

// End settings processor block.

Configure tasks

The behaviors of all tasks above can be customized as follow:, (*20)

<?php
class RoboFile {

  public function myTask() {
    $config = $this->getMyConfiguration();

    $this->taskAppendConfiguration('/my/config.php', $config) // Use custom configuration.
    ->setBlockStart('// Start')                               // Change opening comment.
    ->setBlockEnd('// End')                                   // Change closing comment.
    ->setConfigKey('parameters')                              // Use `parameters:` instead of default `settings:`
    ->run();
  }

}    

Standalone usage

If you just want to use the PHP configuration file processing tasks above in your custom Robo application you can load them by including the following trait:, (*21)

<?php

class RoboFile {

  use \NuvoleWeb\Robo\Task\Config\Php\loadTasks;

}

The Versions

09/01 2018

dev-master

9999999-dev

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

09/01 2018

0.2.1

0.2.1.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

04/01 2018

0.2.0

0.2.0.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

01/07 2017

0.1.3

0.1.3.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

30/06 2017

0.1.2

0.1.2.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

22/06 2017

0.1.1

0.1.1.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

21/06 2017

0.1.0

0.1.0.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

21/06 2017

0.0.2

0.0.2.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco

02/05 2017

0.0.1

0.0.1.0

CI/developer-friendly configuration processor for Robo.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Antonio De Marco