2016-05-20 55 views
2

我是新手,開始與Symfony合作。Symfony 3.0.6沒有看到我的路線

Atm即時通訊從官方symfony快速導覽documentation ...但我堅持控制器!

我敢肯定,我做了同樣的事情,在toutorial又出錯: GET /你好/名稱 「

這裏的「未找到路線」 是我的代碼:

的\ src \的appbundle \控制器\ DefaultController.php

/** 
* @Route("hello/name{name}", name="hello") 
*/ 
public function helloAction($name) 
{ 
    return $this->render('default/hello.html.twig', array(
     'name'=> $name 
    )); 
} 

\程序\資源\意見\ DEFAULT \ hello.html.twig

{%extends 'base.html.twig' %}{% block body %} 
<h1>Hi {{name}}! Welcome to Symfony!</h1>{%endblock%} 
+0

是您的routes.yml配置爲接受來自DefaultController註解路線這不是很清楚嗎? –

回答

3

教程顯示:

/** 
* @Route("hello/{name}", name="hello") 
*/ 

和它的作品,因爲靜態路由部分hello後跟一個參數。

你有​​

你想究竟是什麼,如果你想有/hello/name/xxx,你應該嘗試@Route("hello/name/{name}", name="hello")

+0

我剛剛意識到我犯了愚蠢的錯誤。我在「{name}」之前插入了「名稱」。正如我所說,我是一個新手。感謝您的回答! – Petrus