phpnomad/array-json-config

Maintainers

Package info

github.com/phpnomad/array-json-config

Homepage

pkg:composer/phpnomad/array-json-config

Statistics

Installs: 43

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2024-12-18 16:55 UTC

This package is auto-updated.

Last update: 2026-04-10 02:10:20 UTC


README

Latest Version Total Downloads PHP Version License

phpnomad/array-json-config provides two concrete strategies for phpnomad/config: an in-memory array-backed ConfigStrategy and a JSON file loader that implements ConfigFileLoaderStrategy. This package is just the strategy classes. If you want them wired into a DI container and registered at bootstrap, use phpnomad/json-config-integration, which depends on this package.

Installation

composer require phpnomad/array-json-config

In most PHPNomad applications you install phpnomad/json-config-integration instead, which pulls this package in as a dependency.

Overview

  • ArrayConfigStrategy implements PHPNomad\Config\Interfaces\ConfigStrategy. It holds registered configuration data in a protected array and exposes register(), has(), and get() methods. Lookups support dot notation via PHPNomad\Utils\Helpers\Arr::dot(), so get('database.default.host') walks nested arrays.
  • JsonFileLoader implements PHPNomad\Config\Interfaces\ConfigFileLoaderStrategy. Its loadFileConfigs() method reads a path, runs json_decode(), and throws PHPNomad\Config\Exceptions\ConfigException if the file cannot be parsed into an array.
  • Both classes live under the PHPNomad\ArrayJsonConfig\Strategies namespace.
  • Any code that depends on the phpnomad/config interfaces can consume these strategies without modification.
  • Pair with phpnomad/json-config-integration to bind the strategies to the DI container and register configs against ConfigService at load time.

Documentation

Full documentation for PHPNomad lives at phpnomad.com.

License

MIT. See LICENSE.txt.