承接 adlogix/zf-symfony-container 相关项目开发

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

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

adlogix/zf-symfony-container

Composer 安装命令:

composer require adlogix/zf-symfony-container

包简介

Zend Framework module to leverage the symfony dependency injection container

README 文档

README

Zend Framework module to leverage the symfony dependency injection container

Build Status

Installation

  1. Install the module via composer by running:
composer require adlogix/zf-symfony-container:^0.4
  1. Add the Adlogix\ZfSymfonyContainer module to the module section of your config/application.config.php

Configuration

Symfony Container parameters can be defined in the application configurations:

<?php
return [

    'zf_symfony_container' => [

        // directory where to look for the service container configurations (e.g. config/services.yaml)
        'config_dir' => 'config',

        // Caching options
        'cache' => [

            // directory where the cached container will be stored
            'dir' => 'data/ZfSymfonyContainer',

            // name of the file to generate the cached container class
            'filename' => 'zf_symfony_container_cache',

            // name of the class of the generated cached container
            'classname' => 'CachedContainer',

            // the namespace of the generated cached container
            'namespace' => 'Adlogix\ZfSymfonyContainer\DependencyInjection',

            // enable in dev mode
            'debug' => false
        ],


    ],
];

Usage

Refer to the documentation of the Symfony DI Component for information on how to use the DI container.

Obtain a symfony defined service

Any existing symfony service will directly be available through the Service Manager of Zend:

<?php

$service = $this->getServiceLocator()->get(\My\Public\Service::class);

Build a symfony defined service with a Zend service dependency

It will happen that you have to use a dependency which is already loaded into the Zend Service Manager. For example, if you are using the Doctrine Module and you need to have the instance of the Entity Manager, you can leverage the ZendServiceProxyFactory class:

services:

  _defaults:

    autowire: true      # Automatically injects dependencies in your services.
    autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
    public: false       # Allows optimizing the container by removing unused services; this also means
                        # fetching services directly from the container via $container->get() won't work.
                        # The best practice is to be explicit about your dependencies anyway.

  #
  # Define service that needs to be retrieved via the Zend Service Manager
  #

  Doctrine\ORM\EntityManagerInterface:
    factory: ['Adlogix\ZfSymfonyContainer\Service\Factory\ZendServiceProxyFactory', getService]
    arguments: ['@zend.container', 'doctrine.entitymanager.orm_default']
    class: Doctrine\ORM\EntityManagerInterface

With this configuration, and service defined with the symfony container requiring an instance of Doctrine\ORM\EntityManagerInterface will receive this from the Zend Service Manager.

Obtain the symfony container instance

<?php

$container = $this->getServiceLocator()->get('zf_symfony_container');

Use the Zend config as Symfony parameters

The module takes care of transforming all zend configurations into Symfony parameters allowing you to immediately use the parameters in the service definition file:

<?php
// global.php
return [
    'myconfig' => 'hello world' 
];
services:
  Some\Service:
    arguments: ['%myconfig%']

When the Zend configuration contains deep level keys, the "keys" will be concatenated with a dot.

<?php
// global.php
return [
    'deep' => [
        'level' => [
            'config' => 'hello world'            
        ]    
    ]    
];
services:
  Some\Service:
    arguments: ['%deep.level.config%']

Note: zend configurations using callables will be ignored and cannot be used!

adlogix/zf-symfony-container 适用场景与选型建议

adlogix/zf-symfony-container 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.84k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「dependency injection」 「container」 「symfony」 「zf2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 adlogix/zf-symfony-container 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 adlogix/zf-symfony-container 我们能提供哪些服务?
定制开发 / 二次开发

基于 adlogix/zf-symfony-container 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-19