0
votes

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:

enter image description here

Server:

enter image description here

1
How did you install your module on the server? Where is the module located on your server? Is the directory structure the same as your local development environment? Did you use composer to install it or just copy-and-paste? - Koala Yeung
module --> D8 module ?? it is my custom module .. I am using redhat server . - Arif

1 Answers

0
votes

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.