Symfony2,如何改变环境? [英] Symfony2, How to change environment?

查看:24
本文介绍了Symfony2,如何改变环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多关于 symfony2 的清除缓存命令,但我有这个问题:

I have read a lot about the clear cache command for symfony2, but I have this question :

php app/console cache:clear --env=prod--env 是改变环境还是只是清理该环境的缓存?

Is php app/console cache:clear --env=prod with --env, changes the environment or just clean the cache for that environment?

如果只清除该环境的缓存,那么app.php中的这一行是什么意思:

If only clear the cache for that environment, then what is this line mean in app.php :

$kernel = new AppKernel('prod', false); 

我想当我想使用 Symfony2 生产环境时,我必须将该行更改为

I think when I want to use Symfony2 Production Environment I have to change that line to

$kernel = new AppKernel('prod', true);

我来对地方了吗?

推荐答案

Symfony\Component\HttpKernel\Kernel$environment$debug.

所以,为了直接回答您的问题,app.php 已经使用了生产环境.您会注意到 app_dev.php 像这样实例化内核

So, to answer your question directly, app.php already uses the production environment. You'll notice that app_dev.php instantiates the kernel like this

$kernel = new AppKernel('dev', true); 

因此,您传递给内核构造函数的环境名称映射到您在控制台命令中使用的环境名称(即 --env).

So, the environment name that you pass to the kernel constructor maps to the environment name you'd use in console commands (i.e., the --env).

这对你来说清楚了吗?

这篇关于Symfony2,如何改变环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆