dongyun9120 2013-11-18 16:04
浏览 63

如何将一个巨大的服务配置文件拆分为多个捆绑配置文件

I am trying to split one huge monolithic Symfony2 service configuration file into several smaller files and group them by functionality, etc.

My code:

- app/config/config.yml:

imports:
    - { resource: parameters.yml }
    - { resource: "@YYYCarPartsBundle/Resources/config/parameters.yml" }    
    - { resource: "@XXXShopsBundle/Resources/config/parameters.yml" }   
    ...
    - { resource: "@YYYCarPartsBundle/Resources/config/services.yml" }
    - { resource: "@XXXShopsBundle/Resources/config/services.yml" }         


- YYYCarPartsBundle/Resources/config/services.yml

services:
    car.parts.provider:
        class: YYY\Services\Parts\Provider\Factory
        arguments:
            - .........
            - .........


- XXXShopsBundle/Resources/config/services.yml
services:
    xxx.webservice.client.find.model:
        class: XXX\Soap\ExtendedSoapClient
        arguments:
            - .........
            - "@car.parts.provider"

Unfortunately I am getting this error Fatal error: Uncaught exception

'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'The service "xxx.webservice.client.find.model" has a dependency on a non-existent service "car.parts.provider".' in vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass.php on line 59

I thought container will import all resource files in order, but it does not look like. I am using Symfony 2.3.7. I have tried to define xxx.webservice.client.find.model as lazy service, but no effects.

Any help, explanation would be appreciated.

  • 写回答

1条回答 默认 最新

  • duanlu0559 2013-11-18 16:33
    关注

    You can define services per bundle in in the Resources/config directories without having to explicitly import them, and pretty sure you can use yaml or xml (i.e., src/XXX/ShopsBundle/Resources/config/services.yml)

    评论

报告相同问题?

悬赏问题

  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?