PHP code example of neighborhoods / dependency-injection-container-builder

1. Go to this page and download the library: Download neighborhoods/dependency-injection-container-builder 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/ */

    

neighborhoods / dependency-injection-container-builder example snippets


$container = (new \Neighborhoods\DependencyInjectionContainerBuilderComponent\TinyContainerBuilder())
    ->setContainerBuilder(new \Symfony\Component\DependencyInjection\ContainerBuilder())
    ->setRootPath(dirname(__DIR__))
    ->addSourcePath('src/ComponentName')
    ->addSourcePath('src/Prefab5')
    ->addSourcePath('fab/ComponentName')
    ->makePublic(SomeRepository::class)
    ->addCompilerPass(new \Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass())
    ->addCompilerPass(new \Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass())
    ->build();

$cacheHandler = (new \Neighborhoods\DependencyInjectionContainerBuilderComponent\SymfonyConfigCacheHandler\Builder())
    ->setName('ContainerName')
    ->setCacheDirPath(dirname(__DIR__) . '/data/cache')
    ->setDebug(true)
    ->build();
$container = (new \Neighborhoods\DependencyInjectionContainerBuilderComponent\TinyContainerBuilder())
    // ... 
    ->setCacheHandler($cacheHandler)
    ->build();