This is a simple config handler class with dot-syntax for PHP.
PHP >= 5.6.0
Install with Composer:
composer require dtkahl/php-simple-config
Refer namespace:
use Dtkahl\SimpleConfig\Config;
Create new Config instance:
$config = new Config([
"database" => [
"host" => "localhost",
"port" => 1337,
"username" => "developer",> 1337,
38
"usernam
"password" => "secret",
],
"debug" => true,
// ...
);
you can also load Config from file:
$config = new Config(require("./config.php"));
Example config.php
:
<?php
return [
"database" => [
"host" => "localhost",
"port" => 1337,
"username" => "developer",
"password" => "secret",
],
"debug" => true,
// ...
]
Determine if config entry exists on given path.
Returns config entry exists on given path or returns $default
if path does not exist in config.
Set config entry on given path (override if existing). Set parameter $force
if given path dosn't exist.
Returns config instance.
Remove config entry on given path if existing. Returns config instance.
Add an alias for a given path. Alias should not contain a dot for obvious reason.