PHP code example of jayzeng / config-reader

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

    

jayzeng / config-reader example snippets


use ConfigReader\Ini as IniReader;

// read a specific rule
$username = IniReader::factory( __DIR__ . DIRECTORY_SEPARATOR . 'config.ini' )
                    ->setLabel('production')
                    ->getLabel('username');
                    // returns jayzeng

use ConfigReader\Ini as IniReader;

// read all rules within production section
$prodConfig = IniReader::factory( __DIR__ . DIRECTORY_SEPARATOR . 'config.ini' )
                    ->setLabel('production')
                    ->toArray();

// returns
// array
// 'username' => 'jayzeng'
// 'password' => 'password'

// You can also populate an array
$ips = IniReader::factory( __DIR__ . DIRECTORY_SEPARATOR . 'config.ini' )
                    ->setLabel('whitelistIps')
                    ->toArray();
// returns
// array
// 'ip' => array ( '127.0.0.1', '192.168.0.1/24' );