doupeizheng3918 2014-11-13 07:05
浏览 68
已采纳

DependencyInjection与配置文件中的导入之间的区别

I cant understand what difference between imoprt services in config file, or create DependencyInjection directory:

config.yml:

imports:    
- { resource: @VputiUserBundle/Resources/config/services.xml }

DependencyInjection:

public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);

    $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
    $loader->load('services.xml');
}
  • 写回答

1条回答 默认 最新

  • drktvjp713333 2014-11-13 09:46
    关注

    If you use the full stack symfony2 framework, then there the config for every bundle is loaded by the default behaviour of sf, so you don't have to import it on your config.yml , nevertheless you can't import an xml file in a yml file. The config.yml contain your main configuration for the app, the service configs in the bundle container the services for the bundle. If you are publishing your bundle then there you can share also the services , what resides in your bundle. Also, in the load function, after loading in the services from file, you can manipulate them, if needed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求一个红米手机root以后劫持摄像头教程
  • ¥15 windows2019+nginx+php耗时久
  • ¥15 labelme打不开怎么办
  • ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏
  • ¥15 免费的电脑视频剪辑类软件如何盈利
  • ¥30 MPI读入tif文件并将文件路径分配给各进程时遇到问题
  • ¥15 pycharm中导入模块出错
  • ¥20 Ros2 moveit2 Windows环境配置,有偿,价格可商议。
  • ¥15 有关“完美的代价”问题的代码漏洞
  • ¥15 请帮我看一下这个简易化学配平器的逻辑有什么问题吗?