定制 mrprompt/silex-di-container-provider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrprompt/silex-di-container-provider

最新稳定版本:1.0.3

Composer 安装命令:

composer require mrprompt/silex-di-container-provider

包简介

A simple dependency injection builder to Silex

README 文档

README

Build Status Code Climate Test Coverage Issue Count SensioLabsInsight Dependency Status Codacy Badge

A simple dependency injection builder to Silex based on YAML file config.

Install

composer require mrprompt/silex-di-builder

Usage

Simple create a di.yml - or other name, of course - file with the structure:

services:
  alias1:
    - Full\Class\Name
    - dependency1

  alias2:
    - Full\ClassTwo\Name
    - dependency1
    - dependency2

When:

  • alias1 - Is the alias from Silex
  • Full\Class\Name and Full\ClassTwo\Name - The class name to initialize
  • dependency1 and dependecy2 - Dependencies from the class, must be an alias previously created or anything

In your application bootstrap, register YAML Config Service Provider, with your DI file


use DerAlex\Silex\YamlConfigServiceProvider;
use SilexFriends\DI\Container as DiServiceProvider;

....

$app->register(new YamlConfigServiceProvider(__DIR__ . '/../Resources/di.yml'));
$app->register(new DiServiceProvider($app['config']['services']));
 
# $app['config']['services'] is an array with yml content, created by YamlConfigServiceProvider

Now, your services is available on $app container.

Testing

Just run phpunit without parameters

phpunit

Happy Silex Coding :)

统计信息

  • 总下载量: 1.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-25