Symfony2无法找到某个操作的路由

时间:2012-11-26 16:57:43

标签: symfony routes

我正在使用google驱动器api捆绑文件。我在IndexAction中有一个if,如果用户需要提供权限或已经给出。如果需要,我会从谷歌获取网址并重定向到该链接。

在谷歌控制台中,我将其作为重定向链接:

www.googlebundle/firstTime

在我的GoogleDriveController中,我有

public function firstTimeAction() {
       (...)
}

在我的路由中,我得到了这个:

FilesGoogleDriveBundle_firstTime:
   pattern: /firstTime
   defaults: { _controller: "FilesGoogleDriveBundle:GoogleDrive:firstTime" }
   requirements: { _method: get }

FilesGoogleDriveBundle_homepage:
   pattern:  /Drive/{id}
   defaults: { _controller: FilesGoogleDriveBundle:GoogleDrive:index }

但是我在prod.log中遇到了这个错误:

[2012-11-26 16:50:14] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /firstTime" (uncaught exception) at /var/www/Symfony/app/cache/prod/classes.php line 4564 [] []

有谁知道发生了什么事?

3 个答案:

答案 0 :(得分:1)

首先确保symfony看到您的路由器规则。

在项目根目录中输入

php app/console router:debug | grep FilesGoogleDriveBundle_firstTime

你应该得到这样的东西

FilesGoogleDriveBundle_firstTime   GET    /firstTime

最后一个值是此操作的网址。

答案 1 :(得分:0)

FilesGoogleDriveBundle_firstTime:
   pattern: /firstTime
   defaults: { _controller: FilesGoogleDriveBundle:GoogleDrive:firstTime }
   requirements: 
       _method: GET

试试这个。

答案 2 :(得分:0)

似乎是一个缓存问题,清除了prod环境的缓存:

php app/console cache:clear --env=prod
相关问题