承接 ppokatilo/magic-injection-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ppokatilo/magic-injection-bundle

最新稳定版本:v1.0.3

Composer 安装命令:

composer require ppokatilo/magic-injection-bundle

包简介

Magically inject dependencies into services

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

This Symfony2 bundle provides a way to magically inject dependencies into your services. The dependencies will not be available in the constructor. To use it, you need to complete the following steps:

  1. Add the tag magic_injection.injectable_service to the service you wish to inject. The tag takes an optional argument called type, which you can use to group injectable services.
  2. Add the tag magic_injection.injection_target to the service which should receive the injected services.
  3. Finally, annotate properties with the MagicInjection annotation, which will take an optional type argument that refers to a group of injectable services.

Example usage

  • services.yml
    services:
    
      service.that.will.be.injected:
        class: Service\MyServiceA
        tags:
          - { name: magic_injection.injectable_service, type: my_services }
          
      service.that.has.a.dependency:
        class: Service\MyServiceB
        tags:
          - { name: magic_injection.injection_target }
  • MyServiceB.php
    class MyServiceB
    {
      /**
       * @MagicInjection(type="my_services")
       * @var \Service\MyServiceA
       */
      private $myServiceA;
    
      public function __construct()
      {
        assert($this->myServiceA === null);
      }
      
      public function foo()
      {
        $this->myServiceA->bar();
      }
    }

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固