PHP code example of tomwright / php-config

1. Go to this page and download the library: Download tomwright/php-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/ */

    

tomwright / php-config example snippets


$config = new Config();

$config->put('key', 'value');

$value = $config->get('key');

$config->put('contact', [
    'name' => 'Tom',
    'email' => '[email protected]',
]);

$config->put('contact.name', 'Tom');
$config->put('contact.email', '[email protected]');

$config->put('contact', [
    'name' => 'Tom',
]);

$config->put('contact.email', '[email protected]');

$config->get('contact'); // [ 'name' => 'Tom', 'email' => '[email protected]' ]

$config->get('contact.name'); // Tom
$config->get('contact.email'); // [email protected]

$config = new Config([
    'separator' => '|', // Equal
]);
$config->setSeparator('|'); // Equal

$config->put('contact', [
    'contact' => [
        'name' => 'Tom',
        'email' => '[email protected]',
    ],
]);

$config->get('contact|name'); // Tom
$config->get('contact.email'); // NULL

composer