2017 © Pedro Peláez
 

library config

Fuel package for loading, saving and accessing config settings

image

fuelphp/config

Fuel package for loading, saving and accessing config settings

  • Monday, May 9, 2016
  • by WanWizard
  • Repository
  • 6 Watchers
  • 12 Stars
  • 1,919 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Fuel Config

Build Status Code Coverage Quality Score, (*1)

Fuel package for loading, saving and accessing config settings., (*2)

There are multiple formats in which config files can be handled:, (*3)

  • php
  • json
  • yaml
  • ini

The only odd one is ini. It's the only filetype that can't be automatically formatted for saving. Symfony\Yaml is needed in order to parse and format .yml files., (*4)

Loading

Get a new container, (*5)

use Fuel\Config\Container;

$config = new Container;

We'll need to add a path to load the files from:, (*6)

$config->addPath(__DIR__.'app/config');

Now we're able to load config files., (*7)

$config->load('name');
// Load app/config/name.php into the name group


$other = $config->load('other', false);
// load it, but don't store it

$config->load('data.json');
// Load json data

Default format

It's also possible to set a default config format. By default this is php., (*8)

$config->setDefaultFormat('json');

$data = $config->load('data');
// this will load data.json

Environment settings

An environment will be used to load a secondary config file and will overwrite the default settings., (*9)

$config->setEnvironment('develop');

Saving

It's possible to write all the types (except for ini) to disk., (*10)

$container->save('data');

// or use an alternate location
$container->save('data', 'other/file');

The container is aware of overwrites so it'll always save the config file in the place last loaded, therefor overwriting all that came before., (*11)

Accessing data

The config Container extends the FuelPHP\Common\DataContainer class. Therefor it's possible to retrieve the data in two ways: through ->get and the ArrayAccess way., (*12)

$setting = $config->get('setting');

// is the same as

$setting = $config['setting'];

The first way does allow you to supply a default, (*13)

Contributing

Thank you for considering contribution to FuelPHP framework. Please see CONTRIBUTING for details., (*14)

License

The MIT License (MIT). Please see License File for more information., (*15)

The Versions

09/05 2016

dev-master

9999999-dev https://github.com/fuelphp/config

Fuel package for loading, saving and accessing config settings

  Sources   Download

MIT

The Requires

 

The Development Requires

by FuelPHP Development Team

configuration config