0

Hello I have the same problem with the following code:

first_module.routing.yml:

first_module.content:
  path: '/first'
  defaults:
    _controller: 'Drupal\first_module\Controller\FirstController::content'
    _title: 'Hello world'
  requirements:
    _permission: 'access content'

and the Controller:

<?php

/**
 *  @file
 *  Contains \Drupal\first_module\Controller\FirstController.
 */


 namespace Drupal\first_module\Controller;

 use Drupal\Core\Controller\ControllerBase;


 class FirstController extends ControllerBase {

   public function content() {
     return array(
       '#type' => 'markup',
       '#markup' => t('Hello world'),
     );
   }
 }

And I receive the same "Access Denied" error every time I try to access this page.

closed as off-topic by kiamlaluno May 8 at 11:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

0

As suggested to me from @berramou the solution is:

Add \ to Drupal\first_module\Controller\FirstController::content like \Drupal\first_module\Controller\FirstController::content and clear cash. – berramou 17 mins ago

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