symfony2分支路径链接您请求了一个不存在的服务"&”;


symfony2 twig path links You have requested a non-existent service ""

我有这样的问题:

您请求了一个不存在的服务"

在vendor/symfony/symfoy/src/symfony/Component/DependencyInjection/Container.php中,第264行

我的代码

<p><a href="{{ path('maciej_test_about') }}">About</a></p>

DefaultController.php

<?php
namespace maciej'TestBundle'Controller;
use Symfony'Bundle'FrameworkBundle'Controller'Controller;
class DefaultController extends Controller
{
        public function aboutAction()
    {
        return $this->render('maciejTestBundle:about.html.twig');
    }
}

路由.yml

maciej_test_about:
    path:     /about
    defaults: { _controller: maciejTestBundle:about }

问题出在哪里?

当我查看您的代码时,您在控制器中的模板路径是错误的。

试试这个!

return $this->render('maciejTestBundle:Default:about.html.twig');