PHP code example of legatus / container

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

    

legatus / container example snippets




sr\Container\ContainerInterface as PsrContainer;

$container = new Legatus\Support\Container();

// You can instantiate factories and fetch services from the passed container
$container->register('some-service', static function (PsrContainer $c) {
    return new SomeService(
        $c->get('some-dependency-of-that-service')
    );
});