有没有办法在Symfony2中查看应用程序的配置?

时间:2015-06-26 08:04:37

标签: symfony

Symfony2应用程序将其配置存储在整个应用程序的不同文件中,位于不同的包中。您甚至可以覆盖较低包中的值。

这通常会让您感到困惑,因为您需要知道配置设置是什么,但不知道在哪里查找或无法快速找到它。

当你找到设置时会变得更糟,只是为了稍后意识到该设置实际上并未被使用,因为它被覆盖在其他地方。

是否有命令,插件或任何可以让您在单个位置看到所有配置的内容,它是实际上由Symfony2 使用的方式?

2 个答案:

答案 0 :(得分:1)

您可以使用debug:config(使用别名config:debug)命令获取捆绑包的当前配置。从我所看到的debug:config命令出现在2.5中虽然config:debug可能已经存在了很长时间。

例如,要获取FOSUserBundle的配置,您将使用

app/console debug:config fos_user

答案 1 :(得分:1)

There is nothing you can do to get a complete picture of the whole application at runtime, but you can catch parts of it.

First thing to do is explore the profiler:

sfDebug

You will have access to the Request, the logs, the routing...

What you can do next, if this is not enougth, is dumping the container.

dump($this->container);

From a Controller i.e. This will contains all the parameters, all the service definitions and so on.