我刚开始使用Symfony,所以我正在尝试学习路由。因此,根据Routing的官方文档,我做了一个简单的页面:
<?php
// src/AppBundle/Controller/MainController.php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class MainController extends Controller
{
/**
* @Route("/index", name="Players lister")
*/
public function renderFirstPage()
{
return $this->render('accounts.html.twig');
}
/**
* @Route("/index/{account}", name="Players lister")
*/
public function getPlayersList($account)
{
$players = array("Player1", "Player2");
return $this->render('accounts.html.twig', array(
'account' => $account,
'players' => $players
));
}
}
?>
但是当我去http://localhost:8000/app_dev.php/index
时,我得到No route found for "GET /index"
而第二条路线运行良好。相反,如果我删除第二条路线,第一条路线就会起作用。
我做错了什么?