1. Go to this page and download the library: Download v-dem/queasy-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/ */
// $databaseName will contain 'default' if 'name' and/or 'database' options are missing
$databaseName = $config->get('database', [])->get('name', 'default');
// $databaseName will contain 'default' if 'name' and/or 'database' options are missing
$databaseName = $config('database', [])('name', 'default');
return [
'connection' => [
'driver' => 'mysql',
'host' => 'localhost',
'name' => 'test',
'user' => 'root',
'password' => 'secret'
],
'queries' => new queasy\config\Config('queries.php') // Can be config of another type (INI, JSON etc)
];
return [
'selectActiveUsers' => 'SELECT * FROM `users` WHERE `is_active` = 1'
];
$config = new queasy\config\Config('config.php');
$query = $config['queries']['selectActiveUsers'];
[connection]
driver = mysql
host = localhost
name = test
user = root
password = secret
queries = "@queasy:new queasy\config\Config('queries.ini')"
$defaultConfig = new queasy\config\Config('defaults.php');
$optionalConfig = new queasy\config\Config($arrayWithOptionsToAddOrOverride);
$defaultConfig->merge($optionalConfig);