opensourcerefinery/yaml2pimple
最新稳定版本:2.0.1
Composer 安装命令:
composer require opensourcerefinery/yaml2pimple
包简介
Build a Pimple/Container from a config file
README 文档
README
Simple tool build pimple containers from a configuration file
Imagine this simple application:
use Pimple\Container; $container = new Container(); $container['name'] = 'Gonzalo'; $container['Curl'] = function () { return new Curl(); }; $container['Proxy'] = function ($c) { return new Proxy($c['Curl']); }; $container['App'] = function ($c) { return new App($c['Proxy'], $c['name']); }; $app = $container['App']; echo $app->hello();
We define the dependencies with code. But we want to define dependencies using a yml file for example:
parameters:
name: Gonzalo
services:
App:
class: App
arguments: [@Proxy, %name%]
Proxy:
class: Proxy
arguments: [@Curl]
Curl:
class: Curl
With this library we can create a pimple container from this yaml file (similar syntax than Symfony's Dependency Injection Container)
use Pimple\Container; use OpenSourceRefinery\Yaml2Pimple\ContainerBuilder; use OpenSourceRefinery\Yaml2Pimple\YamlFileLoader; use Symfony\Component\Config\FileLocator; $container = new Container(); $builder = new ContainerBuilder($container); $locator = new FileLocator(__DIR__); $loader = new YamlFileLoader($builder, $locator); $loader->load('services.yml'); $app = $container['App']; echo $app->hello();
License
Yaml2Pimple is licensed under the MIT license.
Change Log
1.1.0
- We have a license. Pulled from the original - https://github.com/gonzalo123/yml2pimple/blob/master/LICENSE
1.0.0
- Just because its needed
0.1.1 Forked from opensourcerefinery/yml2pimple
Added the pimple container as the last argument
0.1.0 Forked from opensourcerefinery/yml2pimple
Creating a release to have a stable version.
统计信息
- 总下载量: 17.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-30