Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony 2 routes not found in production

I have routes like: /, /login, /register, etc that work fine in dev environment.

At first i got 404 error when tried to access my site through app.php instead of app_dev.php

Then i followed this advice and cleaned up my cache.

But now i'm getting a blank screen trying to access any of the registered routes like app.php/ or app.php/login.

I found this message in prod.log:

[2012-02-24 11:27:05] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /login" (uncaught exception) at /home/renat/www/ptracker/app/cache/prod/classes.php line 4564 [] []

Here is my routing.yml:

PtrackerTasksBundle:
resource: "@PtrackerTasksBundle/Resources/config/routing.yml"
prefix:   /

PtrackerAuthBundle:
resource: "@PtrackerAuthBundle/Resources/config/routing.yml"
prefix:   /

routing.yml in AuthBundle:

homepage:
pattern:  /
defaults: { _controller: PtrackerAuthBundle:Default:index }

register:
pattern:  /register
defaults: { _controller: PtrackerAuthBundle:Default:register }

login:
pattern:  /login
defaults: { _controller: PtrackerAuthBundle:Default:login }

activate:
pattern:  /activate/{username}/{salt}
defaults: { _controller: PtrackerAuthBundle:Default:activate }

login_check:
pattern:  /login_check

routing.yml in TasksBundle:

tasks:
pattern:  /tasks
defaults: { _controller: PtrackerTasksBundle:Default:index }

tasks_add:
pattern:  /tasks/add
defaults: { _controller: PtrackerTasksBundle:Default:add }  

tasks_view:
pattern:  /tasks/view/{id}
defaults: { _controller: PtrackerTasksBundle:Default:view, id : null }  

tasks_change_responsible:
pattern:  /tasks/change_responsible/{id}/{responsible}
defaults: { _controller: PtrackerTasksBundle:Default:change_responsible, _format: json }  

tasks_change_status:
pattern:  /tasks/change_status/{id}/{status}
defaults: { _controller: PtrackerTasksBundle:Default:change_status, _format: json }    

tasks_edit:
pattern:  /tasks/edit/{id}
defaults: { _controller: PtrackerTasksBundle:Default:edit } 

What did i miss or what am i doing wrong?

like image 943
mennanov Avatar asked Feb 24 '12 07:02

mennanov


2 Answers

First, review in console list of routes (command router:debug). If there you found your routers, then some troubles with clearing cache in my case I delete folder app/cache manually and it works.

For setting PROD environment without cache, in file app.php change to

$kernel = new AppKernel('prod', true);
like image 161
Vasyl Avatar answered Sep 19 '22 09:09

Vasyl


Try clearing cache on prod enviroment.

php app/console cache:clear --env=prod --no-debug
like image 33
Delon Avatar answered Sep 21 '22 09:09

Delon