PHP code example of exts / configured

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

    

exts / configured example snippets


    use Exts\Configured\ConfigLoader;
    use Exts\Configured\Loader\YAML;
    
    $config = new ConfigLoader(new Yaml(__DIR__ . '/config'));
    
    // load data directly from file using dot notation
    // database = filename 'database.yml'
    //
    // yaml data example:
    // -------------------
    //  user: 'example'
    //  pass: 'examplepwd'
    //  host: '127.0.0.1'
    //  tble: 'example_table'
    // -------------------
    
    $dbUser = $config->get('database.user', 'root');
    $dbPass = $config->get('database.pass', 'pass');
    $dbTble = $config->get('database.tble', 'example');
    $dbHost = $config->get('database.host', 'localhost');
    
    var_dump($dbUser, $dbPass, $dbTble, $dbHost);
    
    // you can also load the data as an array object
    // this takes a filename directly you can ample_user');
    var_dump($db['connections']['mysql']['username']);
    
    // Which I think is pretty cool_
    

    use Exts\Configured\ConfigArray;
    use Exts\Configured\ConfigStorage;
    use Exts\Configured\Storage\YAML;
    
    $saveFile = 'example.yml';
    $saveDirectory = __DIR__ . '/config/';
    
    $exampleArrayObject = new ConfigArray(['example', 'data']);
    
    $exampleStorage = new ConfigStorage(new YAML($saveDirectory));
    $exampleStorage->store($saveFile, (array) $exampleArrayObject);