Symfony2 MethodNotAllowedHttpException on live ser

2020-04-02 11:15发布

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

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. 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.

3条回答
smile是对你的礼貌
2楼-- · 2020-04-02 11:38

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

Or try this following command :

php app/console cache:clear -e prod

Otherwise, delete app/cache folder.

查看更多
不美不萌又怎样
3楼-- · 2020-04-02 11:43

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

查看更多
Emotional °昔
4楼-- · 2020-04-02 11:59

Try to run php app/console router:debug | grep user/create to check if this route loaded at all. Maybe you load this route only for specific env.

查看更多
登录 后发表回答