[英]app_dev.php runs the page, but app.php sends 404
I just started working with Symfony2. 我刚刚开始使用Symfony2。 I created a simple controller in
AppBundle
called PageController.php
and it has an action called homeAction(Request $request)
. 我在
AppBundle
创建了一个名为PageController.php
的简单控制器,它具有一个名为homeAction(Request $request)
。 It all works well and all. 一切正常。 Afterwards I ran a command
之后我执行了一个命令
$ php app/console assets:install
and ran the server and everything was alright. 并运行服务器,一切正常。 If I ran
localhost:8000/page/home
(as I set it up in the @Route
), the page would show up as I expect it to. 如果我运行
localhost:8000/page/home
(如我在@Route
设置的@Route
),则该页面将按预期显示。
Now if I run localhost:8000/app.php/page/home
I get a 现在,如果我运行
localhost:8000/app.php/page/home
我会得到一个
404 page not found
404页面不存在
error, while if I run it with localhost:8000/app_dev.php/page/home,
again I get what I want. 错误,如果我使用
localhost:8000/app_dev.php/page/home,
运行它localhost:8000/app_dev.php/page/home,
我又得到了我想要的。
I tried 2 things to fix this (both of which I found here, on StackOverflow), neither worked: 我尝试了2种方法来解决此问题(在StackOverflow上我都在这里找到了这两种方法)都没有用:
I tried to run another command 我试图运行另一个命令
$ php app/console assetic:dump --env=prod
I tried going into .htaccess
folder and change all of the app.php parts to app_dev.php. 我尝试进入
.htaccess
文件夹,并将所有app.php部分更改为app_dev.php。 It didn't work, so I reverted back to app.php 它没有用,所以我回到了app.php
When developing in development (ie app_dev.php
) changes in annotations trigger the internal cache to be updated, thus no need for an action. 在开发中进行开发时(即
app_dev.php
),注释中的更改会触发内部缓存的更新,因此无需执行任何操作。
When, in turn, testing it in production environment (ie app.php
) you might want to clear the production cache first, so the annotations cache (as well as doctrine, compiled twig templates etc.) gets updated. 反过来,当在生产环境(即
app.php
)中对其进行测试时,您可能希望首先清除生产缓存,以便注释缓存(以及原则,已编译的树枝模板等)得到更新。
You achieve this by executing php app/console cache:clear --env=prod
, or short php app/console c:c -e prod
. 您可以通过执行
php app/console cache:clear --env=prod
或简短的php app/console c:c -e prod
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.