PHP code example of wazsmwazsm / config

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

    

wazsmwazsm / config example snippets


return [
	'name' => 'sqlite',
    'connect' => [ 
        'driver'  => 'sqlite',
        'dbname'  => 'database.db',
        'prefix'  => '',
    ],
];

use Config\Config;

Config::load('test_config', 

use Config\Config;
// 获取名称 (配置文件名.配置名)
$name = Config::get('test_config.name'); // sqlite
$connect = Config::get('test_config.connect'); // ['driver'  => 'sqlite','dbname'  => 'database.db','prefix'  => '']
$dbname = Config::get('test_config.connect.dbname'); // database.db

var_dump($name, $connect, $dbname);

use Config\Config;

Config::set('test_config.name', 'somename');

use Config\Config;

$configs = Config::all();
/*
result is 
[
    'test_config' => [
        'name' => 'sqlite',
        'connect' => [ 
            'driver'  => 'sqlite',
            'dbname'  => 'database.db',
            'prefix'  => '',
        ],
    ]
]
*/