PHP code example of andym84 / config

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

    

andym84 / config example snippets



use AndyM84\Config\ConfigContainer;
use AndyM84\Config\Migrator;

// Perform any nfig file for easy use
$cfg = new ConfigContainer(file_get_contents('siteSettings.json'));

echo($cfg->get('configVersion')); // Echos whatever version your configs are at after migration
json
{
    "schema": {
        "configVersion": "int",
        "siteVersion": "str",
        "frontTitle": "str",
        "backTitle": "str",
        "smtp.host": "str",
        "smtp.port": "int",
        "corsOrigins": "str[]"
    },
    "settings": {
        "configVersion": 2,
        "siteVersion": "1.0.0",
        "frontTitle": "Default Title",
        "backTitle": "Default Backend Title",
        "smtp": {
          "host": "localhost",
          "port": 25
        },
        "corsOrigins": [
          "http://localhost",
          "https://mydomain.com"
        ]
    }
}