PHP code example of wdalmut / simplini

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

    

wdalmut / simplini example snippets



$conf = new Config();
$conf->load(__DIR__ . '/my.ini', 'dev');

echo $conf->prod()->a; // will echo "ecco"


$conf = new Config();
$conf->load(__DIR__ . '/my.ini');

var_dump(conf->a); // array(one,two,three)


$conf = new Config();
$conf->load(__DIR__ . '/my.ini');

echo conf->production()->a->b-c; // will echo "hello"


$conf = new Config();
$conf->load(__DIR__ . '/my.ini');

echo $conf->mysql()->db->host; // localhost

echo $conf->redis()->nosql->b->host; // 192.168.2.2


$conf = new Config();
$conf->load(__DIR__ . '/a.ini', true);

echo $conf->prod()->a; // echo ciao
echo $conf->mysql()->host; // echo 192.168.2.2
echo $conf->redis()->host; // echo 192.168.3.3


$conf = new Config();
$conf->load(__DIR__ . '/a.ini', 'dev');

echo $conf->prod()->a; // echo ciao
echo $conf->mysql()->host; // echo localhost
echo $conf->redis()->host; // echo localhost


$conf = new Config();
$conf->load(__DIR__ . '/a.ini', array('dev', 'dm'));

echo $conf->prod()->a; // echo ciao
echo $conf->mysql()->host; // echo 192.168.2.2
echo $conf->redis()->host; // echo localhost