PHP code example of fmihel / php-config

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

    

fmihel / php-config example snippets


<$php
$config=[
    'pics'=>'app/pics/',
    'base'=>'db',
    'pass'=>'xxxx',
    'user'=>'mike',
    'emails'=>[
        'admin'=>'[email protected]',
    ]
];


use fmihel\config\Config;

echo Config::get('pics');// app/pics
echo Config::get('no-def','default');// default
echo Config::get('no-def');  // raise Exception  
echo Config::get('emails',['admin'=>'[email protected]']);  // ['admin'=>'[email protected]']
echo Config::get('emails',['info'=>'[email protected]']);  // ['admin'=>'[email protected]','info'=>'[email protected]']

<$php
$config=[
    'pics'=>'app/pics/',
    'base'=>'db',
    'pass'=>'xxxx',
    'user'=>'mike',
];

<$php
$configTemplate=[
    'pics'=>'string',
    'base'=>'string',
    'pass'=>'string',
    'user'=>'string',
    'age'=>'number',
    'local'=>'bool'
];


use fmihel\config\Config; // после этой строчке
// приложение будет остановлено !!!
// так как структура config отличается от config.template

composer 

app
 |--config.php
 |--index.php


app
 |--config.php
 |--config.template.php
 |--index.php

composer