Skip to content

publishing-kit/config

Repository files navigation

config

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PublishingKit/Config is a simple config container. It can parse the following formats:

  • PHP files (useful for dynamic stuff that can change based on the environment)
  • ini files
  • YAML files

Install

Via Composer

$ composer require publishing-kit/config

Usage

You can simply pass in an array for the configuration:

$values = [
    'foo' => 'bar'
];
$config = new PublishingKit\Config\Config($values);
echo $config->get('foo'); // returns 'bar'

However, in practice you're unlikely to do this. Instead, you will normally use the named constructors to create the config from a file:

$config = PublishingKit\Config\Config::fromFile('config.php');
$multiConfig = PublishingKit\Config\Config::fromFiles([
    'config.php',
    'config.ini',
    'config.yml'
]);

Once you have a config object, you can check for existence with the has() method, and get the value with the get() method, or as a property:

$config->has('foo'); // returns true
$config->get('foo'); // returns 'bar'
$config->foo; // returns 'bar'

Since the config object implements ArrayAccess and IteratorAggregate, you can also loop over them or access properties using array notation.

Config objects are immutable and so cannot be changed once created.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

About

Simple configuration container class

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages