Load configuration from ini files or environment variables.
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
.scrutinizer.yml
LICENSE
README.md
circle.yml
composer.json
composer.lock

README.md

Load configuration from ini files or environment variables.

Manage your project configuration by defining defaults, which are overridden by ini files, which are overridden by and exposed as environment variables.

Documentation: https://php.gt/docs/config


Build status Code quality Code coverage

Example usage:

nginx.conf:

location ~ \.php$ {
    fastcgi_pass    unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param   database_password       super-secret-passw0rd;
    include         fastcgi_params;
}

config.ini:

[app]
namespace = MyApp
debug = true
logging = verbose

[database]
host = db.example.com
schema = local_shop
username = admin
password = admin_pass

[shopapi]
key = jungfnyyguvffubhgvat
secret = guvfvfnybpnyfubcgurerfabguvatsbelbhurer

example.php:

// Load config.ini
$config = new Config("config.ini", [
    "database" => [
        "host" => "localhost",
        "port" => 6612
    ]
]);

echo $config["database"]->host;     // db.example.com
echo $config["database"]->port;     // 6612
echo $config["database"]->password; // super-secret-passw0rd

Features at a glance

TODO: List out features, such as parsing abilities.