JiNexus Config provides simple, in-memory access to configuration data within an
application. It stores configuration as an associative array and exposes it through
explicit accessors, magic property access, and reflection-based getters/setters.
It is intentionally small and has no external dependencies and no I/O — you
decide where the configuration data comes from (files, environment, a database, plain
arrays) and hand it to a Config instance.
- Documentation: https://framework.jinexus.com/documentation
- Issues: https://github.com/jinexus-framework/jinexus-config/issues
- PHP
^8.5
Install via Composer:
composer require jinexus-framework/jinexus-configuse JiNexus\Config\Config\Config;
use JiNexus\Config\Config\Factory\ConfigFactory;
// Directly...
$config = new Config();
// ...or via the factory (returns a fresh Config each call).
$config = ConfigFactory::build();// Set values (fluent — set() returns the Config instance).
$config->set('host', 'localhost')
->set('port', 8080);
// Get a value with an optional default when the key is absent.
$config->get('host'); // 'localhost'
$config->get('timeout'); // null
$config->get('timeout', 30); // 30
// Check for presence (uses array_key_exists, so a key set to null still "has").
$config->has('host'); // true
$config->set('debug', null);
$config->has('debug'); // true__get and __set forward to get() and set(), so you can treat config keys like
properties:
$config->timezone = 'UTC'; // same as $config->set('timezone', 'UTC')
$config->timezone; // 'UTC' — same as $config->get('timezone')
$config->missing; // null$config->setConfig(['a' => 1, 'b' => 2]); // replace the entire store
$config->getConfig(); // ['a' => 1, 'b' => 2]
$config->setConfig(); // reset to []Package-level failures throw JiNexus\Config\ConfigException (a subclass of
\Exception). For example, calling an unsupported magic getter/setter resolved through
AbstractBase::__call throws a ConfigException with a Not implemented: … message.
Config is a deliberately empty subclass of AbstractConfig. Keep it that way — do not
declare real properties for individual config keys, because a declared property shadows
the __get/__set magic and stops that key from flowing into the internal store. If you
want IDE autocompletion for known keys, add @property PHPDoc tags to the class docblock
rather than real properties.
composer install
./vendor/bin/phpunitphpunit.dist.xml is the committed configuration. Use XDEBUG_MODE=off to silence the
local Xdebug notice, and --testdox for readable output:
XDEBUG_MODE=off ./vendor/bin/phpunit --testdoxPlease see CONDUCT.md for the code of conduct. Contributions should include
tests and a CHANGELOG.md entry. See AGENTS.md for detailed build, style,
and workflow conventions.
BSD-3-Clause. See LICENSE.md.