PHP code example of richcongress / bundle-toolbox

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

    

richcongress / bundle-toolbox example snippets


class Configuration extends AbstractConfiguration
{
    public const CONFIG_NODE = 'bundle_toolbox_test';

    protected function buildConfiguration(ArrayNodeDefinition $rootNode): void
    {
        $rootNode
            ->children()
                ->booleanNode('test')->defaultFalse()->end()
            ->end();
    }
}

$this->specificConfiguration = Configuration::get($parameterBag, 'your_sub_configuration');


class BundleExtension extends AbstractExtension
{
    public function load(array $configs, ContainerBuilder $container): void
    {
        $this->parseConfiguration($container, new Configuration(), $configs);
    }
}

public function build(ContainerBuilder $container): void
{
    CompilerPass::add($container);
}

public const MANDATORY_SERVICES = ['service1', 'service2', 'service3'];

public function process(ContainerBuilder $container): void
{
    if (!self::checkMandatoryServices($container)) {
        return;
    }

    // ...
}