eig/configurator

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP Generic Configuration Object

2.1.0 2019-11-13 23:17 UTC

This package is auto-updated.

Last update: 2021-06-01 18:50:26 UTC


README

A Configuration Loader for PHP Packages

Build Status Latest Stable Version License Coverage Status StyleCI Total Downloads Latest Unstable Version

This package is a standalone library to allow you to have easy setup and access to configuration variables in your own php packages.

Supports

PHP

  • 7.2
  • 7.3

Install

composer require eig/configurator

Usage

Include the Configurator class in your application:

use eig\Configurator\Configurator as Config;

Now call instantiate a copy:

$config = new Config("path/to/files");

or load in an array of values

$config = new Config($array, $key); You can mix and match methods of loading config values.

Now you can reference your configuration variable loaded from the files supplied with dot notation on the config object:

$config->get('app.name');

You also have access to several methods: all() -> returns all items get($key) -> returns the item at the key, may be dot notation has($key) -> returns boolean (True/False) if the value exists, may use dot notation load($value, $key) -> load more values into the config object, **Note: $key is only required for adding an array of values. For adding files the file name is used as the top level key.

Facade

To use the library through a Facade use eig\Configurator\Facades\Configurator Then in your code you can load and access your configuration values like so:

/**
* This mehtod is required first to access any configuration values
* Failing to load first will return a null to any calls to items() or get()
*/

Configurator::load($path);

/**
* This method will return all items that are loaded as an array.
*/
Configurator::all(); 

/**
* This method will return the item you specify just like using the array notation on a
* regular Configurator instance
*/
Configurator::get($value);

/**
 * This method will return true or false if the value exists in the config object
 */
Configurator::has($value);

/**
 * This method sets the value provided to the key
 */
Configurator::set($key, $value)

Contributing

To contribute to this project clone the github repository create a new branch with the feature you are creating or bug you are fixing. Write tests to prove your feature or bugfix works then submit a pull request on github.

Roadmap

Roadmap