【发布时间】:2016-04-30 19:30:56
【问题描述】:
我对 Symfony 3 很陌生。我在 AppBundle 本身中创建了控制器文件。没有创建新的捆绑包。现在我正在尝试路由一个新页面,它给出了一个错误。这就是我所做的。
在src\AppBundle\Controller\Patient\PatientController.php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
/**
* @Route("/patient", name="patient_homepage")
*/
public function patientHomeAction(Request $request)
{
// replace this example code with whatever you need
return $this->render('Patient/home.html.twig', array()
);
}
在app\Resources\views\base.html.twig
<a href="{{ path('patient_homepage') }}">Home</a>
这给出了一个错误
"在渲染模板的过程中抛出了异常 (“无法为命名路由“patient_homepage”生成 URL 为 这样的路线不存在。") 在第 118 行的 base.html.twig 中。"
我还需要对app\config\routing.yml 进行任何更改吗?我在这里错过了什么。
【问题讨论】: