PHP code example of flamecore / container

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

    

flamecore / container example snippets


namespace Acme\MyApplication;

use FlameCore\Container\Container;

$container = new Container();

$container->set('foo', new Configuration(...));
if ($container->has('foo')) {
    $value = $container->get('foo'); // Returns Acme\MyApplication\Configuration object
    $container->remove('foo');
}

$container->set('bar', function () {
    return new Configuration(...);
});
$value2 = $container->get('bar'); // Returns Acme\MyApplication\Configuration object

$value3 = $container->getOr('foobar', function () {
    return new Fallback(...);
}); // Returns Acme\MyApplication\Fallback object