1. Go to this page and download the library: Download miladrahimi/phpconfig 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/ */
use MiladRahimi\PhpConfig\Config;
use MiladRahimi\PhpConfig\Repositories\FileRepository;
$repository = new FileRepository('config.php');
$config = new Config($repository);
$mysql_username = $config->get('mysql.username');
use MiladRahimi\PhpConfig\Config;
use MiladRahimi\PhpConfig\Repositories\DirectoryRepository;
$config = new Config(new DirectoryRepository('configs'));
$app_locale_code = $config->get('app.locale.code', 'en');
$mysql_username = $config->get('mysql.username', 'default-username');
use MiladRahimi\PhpConfig\Config;
use MiladRahimi\PhpConfig\Repositories\JsonFileRepository;
$config = new Config(new JsonFileRepository('config.json'));
$app_locale_code = $config->get('app.locale.code', 'en'); // "fa"
use MiladRahimi\PhpConfig\Config;
use MiladRahimi\PhpConfig\Repositories\JsonDirectoryRepository;
$config = new Config(new JsonDirectoryRepository('configs'));
$app_locale_code = $config->get('app.locale.code', 'en'); // "fa"
$mysql_username = $config->get('mysql.username', 'default-username');
namespace MiladRahimi\PhpConfig\Repositories;
interface Repository
{
/**
* Get configuration data
*
* @return array
*/
public function getData(): array;
}