ctorh23/configmanager

Configuration management library for PHP applications.

Maintainers

Package info

github.com/ctorh23/configmanager

pkg:composer/ctorh23/configmanager

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-13 12:33 UTC

This package is auto-updated.

Last update: 2026-03-13 13:07:10 UTC


README

ConfigManager is a lightweight library for managing PHP configuration files with support for Dot-Notation and Lazy Loading.

Installation

The package requires PHP 8.3 or newer.

composer require ctorh23/configmanager

Usage

Configuration File Structure

Create a PHP file, for example app.php, that looks like this:

return [
	'name' => 'My App',
	'env' => $this->env('APP_ENV', 'production'),
	'encryption' => [
		'cipher' => 'AES-256-GCM',
		'key' => $this->env('APP_KEY'),
	],
];

The file must return an array. As you can see, you can use environment variables as configuration settings. The second parameter of the env() method is a default value.

Accessing Configuration Values

Assuming your configuration files are saved in a config/ directory, you must pass the path to this directory to instantiate a ConfigManager object:

use Ctorh23\ConfigManager\ConfigManager;

$confMan = new ConfigManager(__DIR__ . '/config');

echo $confMan->get('app.name'); //Output: My App
echo $confMan->get('app.env'); //Output: production
echo $confMan->get('app.encryption.cipher'); //Output: AES-256-GCM

// Passing a default value as a second parameter
echo $confMan->get('app.logs', 'logs/'); //Output: logs/

You can also dynamically set configuration settings, but you should keep in mind that they are not persisted on the filesystem:

$confMan->set('timezone', 'UTC');
$confMan->set('app.encryption.cipher', 'AES-XTS');

echo $confMan->get('timezone'); //Output: UTC
echo $confMan->get('app.encryption.cipher'); //Output: AES-XTS