2017 © Pedro Peláez
 

library configuration

Read and write configuration parameters to the YAML file.

image

mikeevstropov/configuration

Read and write configuration parameters to the YAML file.

  • Friday, July 14, 2017
  • by mikeevstropov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

mikeevstropov/configuration

Read and write configuration parameters to the YAML file., (*1)

Install

Add dependency by Composer, (*2)

$ composer require mikeevstropov/configuration

Example usage

As example we have following configuration file., (*3)

# app/config/config.yml

my_parameter: my_value

What we can do with it?, (*4)

<?php

namespace Mikeevstropov\Configuration\Configuration;

// origin configuration
$originFile = 'app/config/config.yml';

// modified configuration
$modifiedFile = 'var/temp/config.yml';

// create instance
$configuration = new Configuration(
    $originFile,
    $modifiedFile
);

// get parameter
$value = $configuration->get('my_parameter'); // my_value

// set parameter
// and save it to the file of modified configuration
$configuration->set('my_parameter', 'new_value');

// check it
$configuration->get('my_parameter'); // new_value

// now we can remove instance or exit form runtime
unset($configuration);

// create instance again
$configuration = new Configuration(
    $originFile,
    $modifiedFile
);

// and check saved value
$value = $configuration->get('my_parameter'); // new_value

// it has
$configuration->has('my_parameter'); // true

// remove
$configuration->remove('my_parameter');

// not defined
$configuration->has('my_parameter'); // false

// also you can use "strict getter" to get existed value
// or thrown InvalidArgumentException if not
$configuration->getStrict('my_parameter'); // thrown InvalidArgumentException

// "strict getter" provide type hinting by second argument
// and thrown InvalidArgumentException if does not match
$configuration->getStrict('my_parameter', 'array'); // thrown InvalidArgumentException

// method getAssert provide assertion behaviour by method
// from Webmozart\Assert by second argument
$configuration->getAssert('my_parameter', 'nullOrStringNotEmpty'); // new_value

// arguments following the second will be passed to
// the assertion method from Webmozart\Assert
$configuration->getAssert('my_parameter', 'range', 10, 20); // thrown InvalidArgumentException

As you can see, when we are using setter the value will saved to the file of modified configuration and loaded next time ass well., (*5)

Development

Clone, (*6)

$ git clone https://github.com/mikeevstropov/configuration.git

Go to project, (*7)

$ cd configuration

Install dependencies, (*8)

$ composer install

Set the permissions, (*9)

$ sudo chmod 777 ./var -v -R

Try to test (PHPUnit is required in global scope), (*10)

$ composer test

The Versions

14/07 2017

dev-master

9999999-dev

Read and write configuration parameters to the YAML file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Evstropov

14/07 2017

1.0.4

1.0.4.0

Read and write configuration parameters to the YAML file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Evstropov

13/07 2017

1.0.3

1.0.3.0

Read and write configuration parameters to the YAML file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Evstropov

22/06 2017

1.0.2

1.0.2.0

Read and write configuration parameters to the YAML file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Evstropov

06/06 2017

1.0.1

1.0.1.0

Read and write configuration parameters to the YAML file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Evstropov

06/06 2017

1.0.0

1.0.0.0

Read and write configuration parameters to the YAML file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Evstropov