k0pernikus k0pernikus - 7 days ago 5
PHP Question

Why isn't my Controller working but throwing a FileLoaderException?

I have setup a new Controller and when I run

./app/console router:debug


I get the error:

[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().)


My Controller looks like this:

<?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 [];
}
}

Answer

Annotations require the use of double quotes, in this case:

* @Route("unsupported")

The single quotes throw the error as it complains via: Expected PlainValue, got ''' at position 26

Comments