PHP code example of kaiseki / config

1. Go to this page and download the library: Download kaiseki/config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kaiseki / config example snippets


use Kaiseki\Config\NestedArrayConfig;

$config = new NestedArrayConfig([
    'db' => [
        'host' => 'localhost',
        'port' => 3306,
    ],
]);

$config->string('db.host'); // "localhost"
$config->int('db.port');    // 3306
$config->has('db.user');    // false

$config->string('db.user', 'root');      // default when the key is absent
$config->get('db.password', null, true); // allow null (nullable)

$config = new NestedArrayConfig(['paths' => ['/a', 42, '/b']]);

$config->stringList('paths'); // ['/a', '/b']  — the 42 is dropped, keys re-indexed

$config->stringList('paths', []); // [] when the key is absent

$config = new NestedArrayConfig(['opts' => ['public' => true, 0 => 'ignored', 'label' => 'X']]);

$config->stringKeyedArray('opts'); // ['public' => true, 'label' => 'X']

use Kaiseki\Config\Config;

$config = Config::fromContainer($container); // expects $container->get('config')

$map = Config::initClassMap($container, ['logger' => LoggerInterface::class]);
// ['logger' => <instance from container>]