Example #1
0
/**
 * Retrieve object from DI container by name
 *
 * @param  string $name
 * @param  object|null
 * @access public
 */
function retrieve($name)
{
    if (StaticContainer::has($name)) {
        return StaticContainer::get($name);
    }
    return null;
}
Example #2
0
<?php

/**
 * Phossa Project
 *
 * PHP version 5.4
 *
 * @category  Library
 * @package   Phossa\Ecs
 * @author    Hong Zhang <*****@*****.**>
 * @copyright 2016 phossa.com
 * @license   http://mit-license.org/ MIT License
 * @link      http://www.phossa.com/
 */
/*# declare(strict_types=1); */
use Phossa\Di\Container;
use Phossa\Config\Config;
use Phossa\Config\Cache\Cache;
use Phossa\Di\StaticContainer;
/*
 * start configure
 */
$config = new Config(getenv('PHOSSA_CONFIG'), getenv('PHOSSA_ENV'), 'php', new Cache(getenv('PHOSSA_CACHE')));
/*
 * start dependent injection container
 */
StaticContainer::setContainer((new Container($config->get('di')))->setResolver($config)->add('config', $config));