2017 © Pedro Peláez
 

library config

A simple yet powerful configuration library for PHP

image

fink/config

A simple yet powerful configuration library for PHP

  • Tuesday, November 29, 2016
  • by jannis
  • Repository
  • 1 Watchers
  • 0 Stars
  • 237 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

A simple yet powerful configuration library for PHP

Build Status Coverage Status Code Climate, (*1)

Latest Stable Version Latest Unstable Version License, (*2)

Usage

Given this configuration file in json format:, (*3)

{
  "section": {
    "key": "value"
  }
}

Use the configuration class like the following:, (*4)

use \Fink\config\Configuration;

// create a new instance
$config = new Configuration("config.json", Configuration::JSON);

// access a specific value
echo $config->get("section", "key"); // echoes "value"

Features

Multiple configuration formats

The library currently supports json and ini format. If you want an additional format, open a new issue or pull request., (*5)

Auto detection of configuration format

The second parameter of the class Configuration is optional. So this is equal:, (*6)

config.ini, (*7)

[section]
key = value

config.json, (*8)

{
  "section": {
    "key": "value"
  }
}

Use it as the following, (*9)

use \Fink\config\Configuration;

// create a new instance
$jsonConfig = new Configuration("config.json");
$iniConfig = new Configuration("config.ini");

echo $jsonConfig->get("section", "key"); // echoes "value"
echo $iniConfig->get("section", "key");  // echoes "value", too

Use custom configuration loaders

To create a new (custom) configuration loader, just create a new subclass of \Fink\config\loader\FileConfigurationLoader and implement the methods needed. Be sure to override the static class member $supportedFileTypes as a hint for supported configuration file types. Add the new configuration loader to the list of supported loaders:, (*10)

use \Fink\config\Configuration;

Configuration::addConfigurationLoader(42, YourCustomConfigurationLoader::class);

$config = new Configuration("your-custom-configuration-syntax.type", 42);

Autodetect the correct loader will work for the custom one, too. If your custom loader supports a file type already supported by a predefined one, the loader with the smallest id will handle the configuration file., (*11)

The Versions

29/11 2016

dev-master

9999999-dev

A simple yet powerful configuration library for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

by Jannis Fink

configuration config

24/07 2016

1.0.0

1.0.0.0

A simple yet powerful configuration library for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

by Jannis Fink

configuration config

04/06 2016

0.2.0

0.2.0.0

A simple yet powerful configuration library for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

by Jannis Fink

configuration config

29/05 2016

0.1.2

0.1.2.0

A simple yet powerful configuration library for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

by Jannis Fink

configuration config

20/05 2016

0.1.1

0.1.1.0

A simple yet powerful configuration library for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

by Jannis Fink

configuration config

16/05 2016

0.1.0

0.1.0.0

A simple yet powerful configuration library for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

by Jannis Fink

configuration config