PHP code example of tnapf / config

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

    

tnapf / config example snippets



/**
 * -- src
 * ---- config
 * ------ database.php
 * ---- index.php
 */

# src/config/database.php

return [
    'host' => 'localhost',
    'name' => 'my_database',
    'port' => 1337,
];

# src/index.php

$config = new Tnapf\Config\Config(
    new \Tnapf\Config\ConfigProvider\PhpBackedConfigProvider(__DIR__ . '/config')
);

$config->get('database.host', 'my-default-value'); // 'localhost'