PHP code example of ultra-lite / container

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

    

ultra-lite / container example snippets


$container->set(
    'service-id',
    function (\Psr\Container\ContainerInterface $container) {
        return new \stdClass();
    }
);

return [
    'service-id' =>
        function (\Psr\Container\ContainerInterface $container) {
            return new \stdClass();
        },
];

$container->configureFromFile('/wherever/config/di.php');

$object = $container->get('service-id');

$thingExists = $container->has('service-id');

$container = new \UltraLite\Container\Container();
$delegateContainer = new \UltraLite\CompositeContainer\CompositeContainer(); // or any delegate container
$compositeContainer->addContainer($container); // will vary for other composite containers
$container->setDelegateContainer($myCompositeContainer);