PHP code example of mazentouati / simple-2way-config

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

    

mazentouati / simple-2way-config example snippets


use MazenTouati\Simple2wayConfig\S2WConfigFactory;

$config = S2WConfigFactory::create( __DIR__ . '/demo' );

$host = $config->get('database.drivers.mysql.host');

$config->get('database.drivers.mysql.host');

echo $config->get('somewhere.where.are.you', 'here');
> here

$config->set('database.drivers.mysql.host', '127.0.0.1');

$config->sync();

$config->sync('database');

use MazenTouati\Simple2wayConfig\S2WConfigException;
...
try {
    $config->sync();
} catch (S2WConfigException $e) {
    die($e->getMessage());
}


return [
    'driver' => 'mysql',
    'drivers' => [
        'mysql' => [
            'host' => 'your_host',
            'dbname' => 'your_database',
            'user' => 'your_user',
            'password' => 'your_password',
        ],
    ],
];