I have created a module called dino_roar, whose job is to create a web page. So i have created a dino_roar.routing.yml file which contains this:

  path: /the/dino/says
    _controller: Drupal/dino_roar/Controller/RoarController::roar
    _permission: 'access content'

Next i have created a PHP class called RoarController, which contains this:


namespace Drupal\dino_roar\Controller;

use Symfony\Component\HttpFoundation\Response;

class RoarController {
  public function roar() {
    return new Response('ROOOOOOAR!');

Here's a screenshot of my module's file tree:

dino_roar file tree

When i empty the cache, i get the following error:

ReflectionException: Class Drupal/dino_roar/Controller/RoarController[error]
does not exist in
Stack trace:

I have followed exactly what they say in this tutorial, but it doesn't work.

Is my namespace wrong, or what can it be?


You need to use back slashes in your _controller definition in your routing.yml. Like:

    _controller: Drupal\dino_roar\Controller\RoarController::roar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.