Symfony2:在生产中获得与开发相同的途径 [英] Symfony2: access same route in production as development

查看:88
本文介绍了Symfony2:在生产中获得与开发相同的途径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Symfony2开发一个小应用程序。在我的开发环境中,我可以毫无问题地访问所有路由:

I'm developing a little application using Symfony2. I can access all routes with no problems in my dev environment:

http://symfony/app_dev.php/cp ( symfony在我的主机文件中,可以解析为localhost)

http://symfony/app_dev.php/cp ("symfony" is in my hosts file to resolve to localhost)

但是,只要我尝试在生产环境中访问它,我只得到404错误页面:

However, as soon as I try and access it in the production environment, I just get a 404 error page:

http://symfony/app.php/cp


糟糕!
发生错误服务器返回 404未找到。
东西坏了。请通过[电子邮件]给我们发送电子邮件,并让我们知道发生此错误时您正在做什么。我们将尽快修复它。给您造成的任何不便,请原谅。

Oops! An Error Occurred The server returned a "404 Not Found". Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

在生产环境中查看应用程序之前,是否需要更改/执行某些操作?我没有弄乱任何核心文件(内核/引导程序/应用文件等)。我正在使用Release Candidate 3。

Is there something I need to change/do before I can view my application in production? I've not messed with any of the core files (kernel/bootstrap/app files, etc). I'm using Release Candidate 3.

推荐答案

正如Crozin在其评论中已经提到的那样,您必须重建缓存才能查看您的更改。每次更改配置,路由或模板中的内容时,都需要重建生产缓存。最安全的方法是使用 php app /控制台缓存:clear --env = prod --no-debug (因为CLI在开发模式下运行,默认情况下已启用调试)。

As Crozin already mentioned in his comment, you have to rebuild cache to be able to see your changes. You need to rebuild production cache every time you change something in config, routing or templates. The safest way to do so is using php app/console cache:clear --env=prod --no-debug (as CLI runs in dev mode with debugging enabled by default).

这篇关于Symfony2:在生产中获得与开发相同的途径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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