PHP code example of symplify / set-config-resolver

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

    

symplify / set-config-resolver example snippets


use Symfony\Component\Console\Input\ArgvInput;
use Symplify\EasyCodingStandard\Set\EasyCodingStandardSetProvider;
use Symplify\SetConfigResolver\SetAwareConfigResolver;

$configs = [];

// 1. --config CLI option or local fallback
$configResolver = new SetAwareConfigResolver(new EasyCodingStandardSetProvider(...));
$inputConfig = $configResolver->resolveFromInputWithFallback(new ArgvInput(), ['ecs.php']);

if ($inputConfig !== null) {
    $configs[] = $inputConfig;
}

// 2. "parameters > set" in provided PHP configs
$parameterSetsConfigs = $configResolver->resolveFromParameterSetsFromConfigFiles($configs);
if ($parameterSetsConfigs !== []) {
    $configs = array_merge($configs, $parameterSetsConfigs);
}

// Build DI container
$appKernel = new AppKernel('prod', true);
if ($configs !== []) {
    $appKernel->setConfigs($configs);
}

$appKernel->boot();

$container = $appKernel->getContainer();