简体   繁体   English

app_dev.php运行页面,但是app.php发送404

[英]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上我都在这里找到了这两种方法)都没有用:

  1. I tried to run another command 我试图运行另一个命令

     $ php app/console assetic:dump --env=prod 
  2. 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.

相关问题 Dev在app_dev.php中可见,但在app.php中不可见 - Dev visible in app_dev.php but not visible in app.php Symfony 2 app.php与app_dev.php - Symfony 2 app.php vs app_dev.php Symfony2:主页可以正确显示在/app_dev.php中,但不能正确显示在/app.php中 - Symfony2: home page displayed properly with /app_dev.php but not with /app.php Symfonys 2 app_dev.php给出了一个空白页,而app.php完美运行 - Symfonys 2 app_dev.php gives a blank page while app.php works perfectly Symfony2项目-app_dev.php可以工作,但是app.php在特定页面上具有重定向循环 - Symfony2 project - app_dev.php works but app.php has redirect loop on just specific page Symfony2 app.php 接收 POST 请求作为 GET app_dev.php 工作正常 - Symfony2 app.php receiving POST request as GET app_dev.php works fine 从Symfony2中的开发(app_dev.php)到生产(app.php) - From development (app_dev.php) to production (app.php) in Symfony2 Symfony href应该为app_dev.php和app.php工作 - Symfony href shoud work for app_dev.php and app.php 使用app.php的Symfony错误500,在app_dev.php上运行正常 - Symfony error 500 with app.php, works fine on app_dev.php Symfony2:在 app.php 和 app_dev.php 之间切换,我这样做对吗? - Symfony2 : Switching between app.php and app_dev.php, am I doing it right?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM