PHP code example of zalevsk1y / container-builder

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

    

zalevsk1y / container-builder example snippets


use ContainerBuilder\DI;

$container = new DI();
$container->addDefinitions(__DIR__ . '/config.php');

$instance = $container->set(new ClassName($some_deps));
$instance = $container->get(ClassName::class);


use ContainerBuilder\DI;

$container = new DI();
$container->addDefinitions(__DIR__ . '/config.php');

$instance = $container->get(ClassName::class);
$result = $container->call([$instance, 'methodName'], [$arg1, $arg2, ...]);