PHP code example of dwo / tagged_services

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

    

dwo / tagged_services example snippets


#AppKernel.php

protected function buildContainer()
{
    $container = parent::buildContainer();
    $container->addCompilerPass(new TaggedServicesPass());
}

#FooBundle.php

protected function build(ContainerBuilder $container)
{
    parent::build($container);
    $container->addCompilerPass(new TaggedServicesPass());
}

#MyServiceContainer.php

class MyServiceContainer {

    private $myServices = array();
    private $myFooService;
    
    function __construct(array $myServices) 
    {    
        $this->myServices = $myServices;
        $this->myFooService = $myServices['foo'];
    }
}