Adding Symfony bundle configuration without a config file using ClosureLoader

Code
<?php

namespace FooBundle;

use 
Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use 
Symfony\Component\DependencyInjection\ContainerBuilder;
use 
Symfony\Component\HttpKernel\DependencyInjection\Extension;

// extension class of your bundle
class MyBundleExtension extends Extension
{
    public function 
load(array $configsContainerBuilder $container)
    {
        
// your extension stuff like services
    
}
}


$containerBuilder = new ContainerBuilder();
$extension = new MyBundleExtension();
$containerBuilder->registerExtension($extension);

$loader = new ClosureLoader($containerBuilder);

// add your config values to container (can happen in AppKernel)
$loader->load(function ($containerBuilder) {
    
$containerBuilder->loadFromExtension('my_bundle', array(
        
'key' => 'value',
    ));
});

// is your bundle config of ClosureLoader present?
$myBundleConfig $containerBuilder->getExtensionConfig('my_bundle');

dump($myBundleConfig);
Result
array:1 [
0 => array:1 [
"key" => "value"
]
]
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6