PHP code example of hsntngr / config-loader

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

    

hsntngr / config-loader example snippets


return [
  'user' => 'hsntngr',
  'password' => 'secret'
  ...
];

echo config("database.user");
// hsntngr

return [
    "driver" => "mysql",
    "host" => "127.0.0.1",
    "dbname" => "example",
    "port" => "3306",
    "user" => [
        "name" => "example",
        "password" => "secret",
    ]
];

use Hsntngr\Config\Config;
use Hsntngr\Config\ArrayLoader;

$path = "/path/to/config/directory/";
$config = Config::create(new ArrayLoader($path));
// use YamlLoader for yaml files
$config->load();

// loading single file
$path = "/path/to/config.php";
$config->loadFromFile($path);

config('auth.session.provider');
// database


$config = Config::getInstance();
$config->get('auth.session.provider');


config("auth.api.token", "sample-token")

print_r(config("auth.api"))

// [
//  "driver"  => "driver",
//  "endpoint" => "v1/users",
//  "token" => "sample-token" 
// ]