1. Go to this page and download the library: Download loshmis/simple-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/ */
loshmis / simple-config example snippets
//index.php
\Slim\Slim();
//path to your config directory
define('CONFIG_PATH', __DIR__ . '/config');
$app->container->singleton('config.loader', function($c) {
return new \Loshmis\SimpleConfig\Loader (
CONFIG_PATH,
new Symfony\Component\Finder\Finder
);
});
$app->container->singleton('config', function($c) {
return new \Loshmis\SimpleConfig\Config($c['config.loader']);
});
return [
'name' => 'Test'
];
//get data
$appName = $app->config->get('app.name');
//set data
$app->config->set('app.name', 'Simple Config')
// to check if configuration parameter is set
$app->config->has('app.name') //will return true in this case
function config($key = null, $default = null)
{
$app = \Slim\Slim::getInstance();
if (is_null($key)) return $app->config;
if (is_array($key)) {
return $app->config->set($key);
}
return $app->config->get($key, $default);
}
// to get some configuration data
$appName = config('app.name');
// to set some data
config(['app.name' => 'Simple Config'])
//path to your config directory
define('CONFIG_PATH', __DIR__ . '/config');
$loader = new \Loshmis\SimpleConfig\Loader (
CONFIG_PATH,
new Symfony\Component\Finder\Finder
);
$config = new \Loshmis\SimpleConfig\Config($loader);
//get data
$appName = $config->get('app.name');
//set data
$config->set('app.name', 'Simple Config')
//...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.