phpnomad / array-json-config
1.0.0
2024-12-18 16:55 UTC
Requires (Dev)
- phpnomad/tests: ^0.1.0
This package is auto-updated.
Last update: 2026-04-10 02:10:20 UTC
README
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
ArrayConfigStrategyimplementsPHPNomad\Config\Interfaces\ConfigStrategy. It holds registered configuration data in a protected array and exposesregister(),has(), andget()methods. Lookups support dot notation viaPHPNomad\Utils\Helpers\Arr::dot(), soget('database.default.host')walks nested arrays.JsonFileLoaderimplementsPHPNomad\Config\Interfaces\ConfigFileLoaderStrategy. ItsloadFileConfigs()method reads a path, runsjson_decode(), and throwsPHPNomad\Config\Exceptions\ConfigExceptionif the file cannot be parsed into an array.- Both classes live under the
PHPNomad\ArrayJsonConfig\Strategiesnamespace. - Any code that depends on the
phpnomad/configinterfaces can consume these strategies without modification. - Pair with
phpnomad/json-config-integrationto bind the strategies to the DI container and register configs againstConfigServiceat load time.
Documentation
Full documentation for PHPNomad lives at phpnomad.com.
License
MIT. See LICENSE.txt.