k0pernikus k0pernikus - 2 years ago 116
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:

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:

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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download