PHP code example of phpnomad / json-config-integration

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

    

phpnomad / json-config-integration example snippets




use PHPNomad\Component\JsonConfigIntegration\ConfigInitializer;
use PHPNomad\Config\Services\ConfigService;
use PHPNomad\Loader\Bootstrapper;

$configInitializer = new ConfigInitializer([
    'app'      => __DIR__ . '/config/app.json',
    'database' => __DIR__ . '/config/database.json',
    'mailer'   => __DIR__ . '/config/mailer.json',
]);

$bootstrapper = new Bootstrapper($container, $configInitializer);
$bootstrapper->load();

/** @var ConfigService $config */
$config = $container->get(ConfigService::class);

$config->get('app.debug');             // value from app.json
$config->get('database.default.host'); // nested lookup into database.json
$config->get('mailer.port', 587);      // default fallback