PHP code example of requtize / config

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

    

requtize / config example snippets


$array = [
    'one' => [
        'two' => [
            'three' => 'value'
        ]
    ]
];

// PHP access
$array['one']['two']['three'];

// Dot notation access
$config->get('one.two.three');

// Without cache system
$config = new Config();
// With cache system
$config = new Config('config-filepath.php');

// Import files - multiple formats in the same way
$config->import('filename.php');
$config->import('filename.ini');
$config->import('filename.yaml');
// Or import as array
$config->import([ 'filename.php', 'filename.ini', 'filename.yaml' ]);

// Get value - each index in multidimensional array separate by dot
// Default value will be returned if given key(s) will not be existed
$value = $config->get('some.deep.index.in-config.file', 'default value');

// Set value in current request live (and in cache).
$config->set('key', 'some value to save');

// Key exists?
$config->has('key') ? 'yes' : 'no';

// Get all data in configs (in all files)
$config->all();

return [
    // Other data...
    'imports' => [
        'filepath.php',
        '../../global-config/main.ini',
        './some-yaml.file.yaml'
    ]
    // Other data...
];
yaml
# Other data...
imports:
    "filepath.php"
    "../../global-config/main.ini"
    "./some-yaml.file.yaml"
# Other data...
ini
; Other data...
[imports]
0 = "filepath.php"
1 = "../../global-config/main.ini"
2 = "./some-yaml.file.yaml"
; Other data...