phpactor/config-loader

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

Library to load (user) configuration

0.1.2 2021-02-06 14:38 UTC

This package is auto-updated.

Last update: 2022-03-20 17:02:09 UTC


README

CI

Library to load an application configuration file

Usage

$loader = new ConfigLoader(
    new Deserializers([
        'json' => new JsonDeserializer(),
    ]),
    new PathCandidates([
        new XdgPathCandidate('myapp', 'config.json', 'json'),
        new AbsolutePathCandidate(getcwd() . '/' . 'myapp.json', 'json'),
    ])
);
$config = $loader->load();

The above will:

  • Load existing config from XDG config directory for myapp (e.g. $HOME/.config/myapp/config.json).
  • Merge existing config from the current working directory if it exists.

Deserializers

  • JsonDeserializer: Deserializes using json_decode. Very fast.
  • YamlDeserializer: Deserializes using the Symfony YAML parser requires symfony/yaml

Path Candidates

  • XdgPathCandidate: Represents candidate config file in the XDG config path for an application.
  • AbsolutePathCandidate: Represents an arbitrary config file at an absolute path.

Contributing

This package is open source and welcomes contributions! Feel free to open a pull request on this repository.

Support

  • Create an issue on the main Phpactor repository.
  • Join the #phpactor channel on the Slack Symfony Devs channel.