PHP code example of chrissileinus / config-php

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

    

chrissileinus / config-php example snippets


Config\Storage::integrate(
  // default values
  [
    'database' => [
      'host' => "localhost",
      'port' => 3306,
      'name' => "databasename",
      'user' => "username",
      'pass' => "fdsgsdgs",
    ],
    'log' => [
      'timezone' => "UTC",
      'console' => [
        'level' => Log\Level::NONE,
        'ignore' => [],
      ]
    ]
  ],
  // default value get replaced by values from config files.
  '/etc/App/*.yaml',
  '/etc/App/*.json'
);

$dbConfig = Config\Storage::getInstance()['database'];
$db = new PDO("mysql:host={$dbConfig['host']};port={$dbConfig['port']};dbname={$dbConfig['name']}", $dbConfig['user'], $dbConfig['pass']);