简体   繁体   English

symfony2-独立dic

[英]symfony2 - standalone dic

I have tried to use symfony2 standalone dependency injection container in a custom MVC application. 我试图在自定义MVC应用程序中使用symfony2独立依赖项注入容器。 But I am not sure how to access the services registered in the files across my application. 但是我不确定如何在整个应用程序中访问文件中注册的服务。 Since I am not using the entire symfony framework what is the best way to access the services in the container. 由于我没有使用整个symfony框架,因此什么是访问容器中服务的最佳方法。

You can read about Symfony DIC here: http://symfony.com/doc/current/components/dependency_injection/introduction.html 您可以在此处阅读有关Symfony DIC的信息: http : //symfony.com/doc/current/components/dependency_injection/introduction.html

It pretty much covers the whole thing. 它几乎涵盖了整个内容。

Did you check this out: http://symfony.com/doc/current/components/dependency_injection/introduction.html ? 您是否检查过此网址http : //symfony.com/doc/current/components/dependency_injection/introduction.html

Your project can only depend on the DependencyInjection Component ( https://github.com/symfony/DependencyInjection ). 您的项目只能依赖于DependencyInjection组件( https://github.com/symfony/DependencyInjection )。

Result of a DI-setup is always the container itself. DI设置的结果始终是容器本身。 You can access it via Container::get($id) 您可以通过Container::get($id)访问它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM