简体   繁体   English

实时服务器上的Symfony2 MethodNotAllowedHttpException

[英]Symfony2 MethodNotAllowedHttpException on live server

I am getting below error on live server: 我在实时服务器上收到以下错误:

request.ERROR: Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException: "No route found for "GET user/create: Method Not Allowed (Allow: POST)" at /home/public_html/project/app/cache/prod/classes.php line 3685 request.ERROR:未捕获的PHP异常Symfony \\ Component \\ HttpKernel \\ Exception \\ MethodNotAllowedHttpException:“在/ home / public_html / project / app / cache / prod中找不到”GET user / create:Method Not Allowed(Allow:POST)“的路由/classes.php第3685行

but I am not getting this error on a local machine with the same code. 但我没有在具有相同代码的本地计算机上收到此错误。

Solutions points to clearing the cache, but I am not able to get how we can clear cache on a live server. 解决方案指向清除缓存,但我无法获得如何清除实时服务器上的缓存。

I also deleted cache folder from live server, but the issue still persists. 我还从实时服务器删除了缓存文件夹,但问题仍然存在。

UPDATE: The issue is surprisingly solved after updating base.html.twig file. 更新:更新base.html.twig文件后,问题出乎意料地得到解决。 i think cache regenerates again with some dependencies after that. 我认为缓存会在之后再次出现一些依赖关系。 but still i did not get how it is resolved as deleting cache folder does not resolved it but changes in base.html.twig file does the job. 但仍然没有得到如何解决因为删除缓存文件夹没有解决它,但base.html.twig文件中的更改完成了这项工作。

Try to run php app/console router:debug | grep user/create 尝试运行php app/console router:debug | grep user/create php app/console router:debug | grep user/create to check if this route loaded at all. php app/console router:debug | grep user/create来检查这条路由是否已加载。 Maybe you load this route only for specific env. 也许你只为特定的环境加载这条路线。

It's because you have to call you route with "POST method. Try to remove @Method("POST") in you controller or Add GET with @Route("GET","POST"). Documentation 这是因为你有给你打电话与航线“POST方法。尝试删除@method”在你的控制器或添加与@Route GET(“POST)(” GET”,‘POST’)。 文档

Or try this following command : 或者尝试以下命令:

php app/console cache:clear -e prod

Otherwise, delete app/cache folder. 否则,删除app / cache文件夹。

Try 尝试

rm -rf app/cache/*
rm -rf app/logs/*

chmod 777 app/cache/
chmod 777 app/logs/

If problem solved, read more in "Setting up Permissions" section: http://symfony.com/doc/current/book/installation.html 如果问题解决了,请阅读“设置权限”部分中的更多内容: http//symfony.com/doc/current/book/installation.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM