2017 © Pedro Peláez
 

library zaolik

yet another DIContainer

image

t_ishida/zaolik

yet another DIContainer

  • Wednesday, November 25, 2015
  • by t-ishida
  • Repository
  • 1 Watchers
  • 1 Stars
  • 99 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Zaolik

yet another PHP DI Container inspired by Phalcon, (*1)

How To Use

$container = \Zaolik\DIContainer::getInstance();
$databaseConfig = array (
    'host' => 'localhost',
    'user' => 'user',
    'pass' => 'pass',
    'database' => 'test',
);
$memcacheConfig = array (
    'hosts' => 'localhost',
    'port' => 11211,
);

$container->setFlyweight('mysqli', function () use ($databaseConfig) {
    $mysql = new \mysqli($databaseConfig['host'], $databaseConfig['user'], $databaseConfig['pass']);
    $mysql->select_db($config['database']);
    return $mysql; 
})->
setNew('DateTime', function ($time = null) {
    return new \DateTime($time);
});

// new instance
$mysqli1 = $container->getFlyWieght('mysqli');

// flyweight 
$mysqli2 = $container->getFlyWieght('mysqli');
echo $mysqli1 === $mysqli2 . "\n"

// now
echo $container->getNewInstance('DateTime') . "\n";

// yester day
echo $container->getNewInstance('DateTime', '-1 day') . "\n";

License

This library is available under the MIT license. See the LICENSE file for more info., (*2)

The Versions

25/11 2015

dev-master

9999999-dev

yet another DIContainer

  Sources   Download

MIT License

The Development Requires

by Takeshi Ishida