這是我的路線Symfony的2 - 不能得到變量
homepage:
pattern: /{name}.{ext}
defaults:
_controller: DprocMainBundle:Index:index
name: index
ext: php
requirements:
ext: php
name: index
,我想在我的樹枝模板來顯示(名稱)。所以控制器得到變量,並通過數組將其發送
class IndexController extends Controller
{
public function indexAction($index)
{
return $this->render('DprocMainBundle:Dproc:index.html.twig', array('index' => $index));
}
}
意見
<title>{% block title %}Welcome - {{ name }}{% endblock %}</title>
有錯誤:
Controller "Dproc\MainBundle\Controller\IndexController::indexAction()" requires that you provide a value for the "$index" argument (because there is no default value or because there is a non optional argument after this one).
將'$ index'更改爲'$ name' – tttony