简体   繁体   English

如何在symfony2中禁用数据库配置

[英]how to disable database configuration in symfony2

The new app I'm working on is using Symfony2. 我正在开发的新应用程序正在使用Symfony2。 There is no database connection to use. 没有数据库连接可供使用。 Instead it's build upon many web service calls. 相反,它建立在许多Web服务调用之上。 Under Symfony/app/config, I would like to remove all database_* entries but when I do that, I get a 在Symfony / app / config下,我想删除所有的database_ *条目,但是当我这样做时,我得到一个

ParameterNotFoundException: You have requested a non-existent parameter "database_driver"

The error is obvious. 错误很明显。 But how do I decouple and remove the database configs from the app itself? 但是,如何从应用程序本身中解耦和删除数据库配置?

Remove DoctrineBundle initialisation from your AppKernel and doctrine configuration from your app/config/config*.yml files. app/config/config*.yml文件中删除Apptrernel和doctrine配置中的DoctrineBundle初始化。 It registers doctrine configuration in the container. 它在容器中注册了doctrine配置。 That's why container complains if you try removing the parameters (bundle is enabled and looks for those parameters). 这就是为什么容器会在你尝试删除参数时抱怨的原因(bundle已启用并查找这些参数)。

In latest versions of Symfony you'll also need to remove the doctrine channel from monolog configuration in config_dev.yml (remove the channels: ["doctrine"] line). 在Symfony的最新版本中,你还需要从独白配置中删除学说通道config_dev.yml (删除channels: ["doctrine"]行)。

Symfony2 is integrated with Doctrine2 by default. Symfony2默认与Doctrine2集成。 You cannnot remove the configuration, unless you set another integration bundle. 除非您设置另一个集成包,否则无法删除配置。

It would be effortless if you simply leave these fields empty. 如果你只是将这些字段留空,那将毫不费力。 A connection to the database would be made only when the application requires it, which, in your case, should not happen. 只有在应用程序需要时才会建立与数据库的连接,在您的情况下,不应该这样做。

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

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