我制作了一个新的 Symfony2 包并删除了 Acme 包。
然后我创建了一个新的控制器(MainController.php
):
<?php
namespace My\BlogBundle\Controller;
class MainController extends Controller
{
/**
* @Route("/", name="index")
* @Template()
*/
public function indexAction()
{
return array();
}
和一个简单的观点: ( Main/index.html.twig
) 其中只包含一个hello
. 我的 routing.yml 是空的。当我运行整个项目时,我得到:
No route found for "GET /"
404 Not Found - NotFoundHttpException
1 linked Exception: ResourceNotFoundException »
这里有什么问题以及如何解决?
这是我的路由调试:
\Symfony>php app/console router:debug
[router] Current routes
Name Method Pattern
_wdt ANY /_wdt/{token}
_profiler_search ANY /_profiler/search
_profiler_purge ANY /_profiler/purge
_profiler_info ANY /_profiler/info/{about}
_profiler_import ANY /_profiler/import
_profiler_export ANY /_profiler/export/{token}.txt
_profiler_phpinfo ANY /_profiler/phpinfo
_profiler_search_results ANY /_profiler/{token}/search/results
_profiler ANY /_profiler/{token}
_profiler_redirect ANY /_profiler/
_configurator_home ANY /_configurator/
_configurator_step ANY /_configurator/step/{index}
_configurator_final ANY /_configurator/final
我也清除了缓存,但没有成功。
这是 routes.yml:
my_blog:
resource: "@MyBlogBundle/Resources/config/routing.yml"
prefix: /
而且里面的 routing.ymlMyBlogBundle/Resources/config/routing.yml
是空的。