Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 588
jit Avatar asked Jul 26 '15 06:07

jit


3 Answers

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.

like image 58
pomaxa Avatar answered Nov 14 '22 15:11

pomaxa


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.

like image 39
callmemath Avatar answered Nov 14 '22 14:11

callmemath


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

like image 3
Max Lipsky Avatar answered Nov 14 '22 13:11

Max Lipsky