PHP configuration manager package
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)
- YAML files
$ composer require publishing-kit/config
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
IteratorAggregate, you can also loop over them or access properties using array notation.
Config objects are immutable and so cannot be changed once created.
Please see CHANGELOG for more information on what has changed recently.
$ composer test
If you discover any security related issues, please email firstname.lastname@example.org instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.