PHP code example of devuri / config

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

    

devuri / config example snippets


use Urisoft\SimpleConfig;

// Define your configuration path and allowed files
$configPath = __DIR__ . '/config';
$allowedFiles = ['app', 'database'];

// Instantiate the SimpleConfig object
$config = new SimpleConfig($configPath, $allowedFiles, 'production', 'path/to/configCache.php');

// Access configuration values
$appName = $config->get('app.name');
$dbHost = $config->get('database.connections.mysql.host');

// Set a new configuration value
$config->set('app.timezone', 'UTC');

// Retrieve the newly set value
echo $config->get('app.timezone'); // Outputs: UTC

// Manually clear the configuration cache
$config->clearCache();