Download the PHP package nordcode/robo-parameters without Composer
On this page you can find all versions of the php package nordcode/robo-parameters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nordcode/robo-parameters
More information about nordcode/robo-parameters
Files in nordcode/robo-parameters
Package robo-parameters
Short Description Parameter file writer for Robo task runner
License MIT
Informations about the package robo-parameters
Robo Parameters Task
Robo Parameters provides tasks for the Robo PHP task runner to read and write parameters from/to files with various formats. You can read a parameter file to configure you tasks from a central file or write parameters to a configuration file for your own application to support your deployment setup
Currently, we support xml
, ini
, php
, yaml
and json
files.
The library comes with a dedicated task for Symfony parameter
files that supports the Symfony XML and YAML format
(currently no support for the Symfony PHP-configuration format).
Installation
Simply add the library as dependency to your composer.json
(you will mostly only require this in dev):
or via console:
If you need the YAML reader/writer you will have to add the symfony/yaml
component, too!
Usage
After installation you need to add the to your RoboFile by importing the trait:
Examples
Let's start with some examples. For detailed information on the different configuration options please see the reference at the end of this file.
Basic usage
Write with reading from boilerplate
Write Symfony parameters.yml
Use with Laravel (dotenv files)
Parameters
Task Reference
A new instance can be created with $this->writeParameters($path, $format = null)
when using the loadTasks
trait.
->set(string $key, mixed $value)
, ->set(array $values)
Set a parameter to a fixed value. Does also accept a list of key => value pairs
->loadFromEnvironment(array $parameter_names)
Will attempt to load the parameter names from the environment variables.
The parameter names will always be uppercased, e.g. loading the parameter foo_bar
will look for FOO_BAR
in the environment
->envVariablePrefix(string $prefix)
Requires all parameters in the environment to be prefixed with the given values.
The prefix also follows the uppercase scheme, so loading foo
with sf
as prefix will actually search for SF_FOO
->failOnMissingEnvVariables()
Will make the task fail if one of the parameters set with ->loadFromEnvironment()
could not be found
->fileHeader(array $lines)
, ->fileHeader(string $header)
Add a comment as header to the output file. The comment will always the correct syntax for the output format.
This can either be a string or an array of lines
->useBoilerplate(string $path)
Load all parameters from the given file
->overrideExisting()
Explicitly override the parameters file if it is already existing.
If this is not set the task will fail by default!
SymfonyParameters
Task Reference
The dedicated Symfony task has the same methods as the Parameters
task.
When using the loadTask
trait a new instance will be created with $this->writeSymfonyParameters()
by default
this uses the YAML format and will try to load the app/config/parameters.yml.dist
and write the final values to
app/config/parameters.yml
.
The FileConfigurable
Task
If you would like to make your own task more dynamically by loading some settings from a central file, you can use
the FileConfigurable
trait: