When I going to clear cache from admin panel, error appears:
The website encountered an unexpected error. Please try again later.ReflectionException: Class Drupal\mymodule\Controller\MyClass does not exist in ReflectionMethod->__construct() (line 136 of core/lib/Drupal/Core/Entity/EntityResolverManager.php). Drupal\Core\Entity\EntityResolverManager->setParametersFromReflection(Array, Object) (Line: 221)
But at my local system there is no error.
I did some R & D with it. I found some difference between my local phpinfo and server phpinfo. Found different between. Different found at Reflection property.
For my local there display some version of Reflection , but at server no version found.
Local:
Server:
Best way to use created controller under the src like (modules/yourmodule/src/Controller/xyzController.php).
Rout path will be:
yourmodule.payrs:
path: '/thank-you'
defaults:
_title: 'Thank You'
_controller: '\Drupal\yourmodule\Controller\xyzController::abc'
requirements:
_permission: 'access content'
options:
no_cache: 'TRUE'
Good luck.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.