mattjmattj / manioc
基于Maybe和Pimple的IoC容器
1.0
2015-03-21 01:17 UTC
Requires
- mattjmattj/maybe: ~1.0
- pimple/pimple: ~3.0
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2024-09-12 04:15:43 UTC
README
基于Maybe和Pimple的IoC容器。Manioc实际上直接依赖于Pimple 3,并使用Maybe扩展它。
安装
使用composer
composer.phar require mattjmattj/manioc ~1.0
基本用法
use Manioc\Container; [...] $container = new Container(); // A Manioc container is a Pimple 3 container $container['feature.foo.enabled'] = false; $container['Cache'] = function($c) { new Cache(); } // ...but with Maybe! Here we use a feature switch to build an instance of Foo // and wrap it with Maybe. If feature.foo is disabled, Maybe will provide a fake // object $container['Foo'] = $container->maybe('Foo',function($c) { if ($c['feature.foo.enabled']) { return new Foo(); } }); // we can also register factories: $container['Foo'] = $container->maybeFactory('Foo',function($c) { if ($c['feature.foo.enabled']) { return new Foo(); } });
许可证
Manioc遵循BSD-2-Clause许可证。