为什么我的控制器没有工作但抛出FileLoaderException?

时间:2015-01-26 10:46:10

标签: php symfony routing annotations

我设置了一个新的控制器,当我运行时

./app/console router:debug

我收到错误:

[Symfony\Component\Config\Exception\FileLoaderLoadException]                                                                                                                                               
  Cannot import resource "/home/dev/Workspace/src/Hn/AssetDbBundle/Controller/" from "/home/dev/Workspace/app/config/routing.yml". ([Syntax Error] Expected PlainValue, got ''' at position 26 in method Hn\AssetDbBundle\Controller\Component\UnsupportedBrowserController::renderUnsupportedBrowserMessageAction().)

我的控制器看起来像这样:

<?php
namespace Hn\AssetDbBundle\Controller\Component;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class UnsupportedBrowserController
 * @Route("/_internal/browser/", name="component_browser")
 * 
 */
class UnsupportedBrowserController extends Controller
{
    /**
     * @Template()
     * @Route('unsupported')
     */
    public function renderUnsupportedBrowserMessageAction()
    {
        return [];
    }
}

1 个答案:

答案 0 :(得分:5)

注释需要使用双引号,在这种情况下:

* @Route("unsupported")

单引号通过以下方式抛出错误:Expected PlainValue, got ''' at position 26