Я создал модуль в Drupal 8, и после добавления маршрутизации я получил уведомление в сообщениях журнала, в котором говорилось:
Notice: Undefined index: path in Drupal\Core\Routing\RouteBuilder->rebuild() (line 172 of /home/...
мой модуль routing.yml выглядит так:
---
mymodule.mypage:
path: /mypage
defaults:
_controller: Drupal\mymodule\Controller\MyPageController::customPage
_title: My custom page
requirements:
_role: anonymous
Зайдя на страницу, я получил это сообщение:
Access denied You are not authorized to access this page.



Мне кажется, что отступы неправильные. И, возможно, проверяйте не роль, а разрешение access content.
mymodule.mypage:
path: '/mypage'
defaults:
_controller: 'Drupal\mymodule\Controller\MyPageController::customPage'
_title: 'My custom page'
requirements:
_permission: 'access content'