how to disable database configuration in symfony2

2020-03-12 05:27发布

The new app I'm working on is using Symfony2. There is no database connection to use. Instead it's build upon many web service calls. Under Symfony/app/config, I would like to remove all database_* entries but when I do that, I get a

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?

标签: php symfony
2条回答
爷、活的狠高调
2楼-- · 2020-03-12 06:07

Symfony2 is integrated with Doctrine2 by default. 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.

查看更多
放荡不羁爱自由
3楼-- · 2020-03-12 06:09

Remove DoctrineBundle initialisation from your AppKernel and doctrine configuration from your app/config/config*.yml files. It registers doctrine configuration in the container. That's why container complains if you try removing the parameters (bundle is enabled and looks for those parameters).

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).

查看更多
登录 后发表回答