felipecwb / container
A Simple PHP Data Container.
1.0
2016-11-17 11:15 UTC
Requires (Dev)
- phpunit/phpunit: 5.5.*
This package is not auto-updated.
Last update: 2024-10-26 20:32:20 UTC
README
A Simple PHP Data Container
composer require "felipecwb/container"
use Felipecwb\Container; $container = new Container(); $container->set('config', [ 'environment' => 'dev', 'database' => 'sqlite::memory:' ]); $container->get('config'); // Array $container->set('db', function ($c) { // Container instance as first argument on closures $config = $c->get('config'); return new PDO( $config['database'], null, null, array(PDO::ATTR_PERSISTENT => true) ); }); //lazy load $container->getDb(); //PDO