本文介绍了在生产中找不到symfony 2条路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有诸如/,/ login,/ register之类的路由,它们在开发环境中都能正常工作。

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

起初,当我尝试访问我的计算机时出现404错误通过app.php而不是app_dev.php

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.

但是现在我得到了一个空白屏幕,试图访问任何已注册的路由,例如app.php /或app.php / login。

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

我在prod.log中发现此消息:

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 [] []

这是我的路由。yml:

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:

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在TasksBundle中:

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?

推荐答案

首先,在控制台的路由列表中进行检查(命令 router:debug )。
如果您找到了路由器,就我而言,清除缓存会遇到一些麻烦,我会手动删除文件夹 app / cache 并起作用。

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.

要设置没有缓存的PROD环境,请在文件 app.php 中更改为

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

$kernel = new AppKernel('prod', true);

这篇关于在生产中找不到symfony 2条路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 10:41