【问题标题】:ReflectionException error appears at Drupal 8 project when I am going to clear cache当我要清除缓存时,Drupal 8 项目中出现 ReflectionException 错误
【发布时间】:2019-09-23 09:50:44
【问题描述】:

当我要从管理面板清除缓存时,出现错误:

网站遇到意外错误。请再试一次 后来.ReflectionException: 类 Drupal\mymodule\Controller\MyClass 在 ReflectionMethod->__construct() 中不存在(core/lib/Drupal/Core/Entity/EntityResolverManager.php 的第 136 行)。 Drupal\Core\Entity\EntityResolverManager->setParametersFromReflection(Array, 对象)(行:221)

但在我的本地系统中没有错误。

我对它进行了一些研发。 我发现我的本地 phpinfo 和服务器 phpinfo 之间存在一些差异。发现之间不一样。在 Reflection 属性中发现不同。

对于我的本地显示某些版本的 Reflection ,但在服务器上找不到版本。

本地:

服务器:

【问题讨论】:

  • 你是如何在服务器上安装你的模块的?模块在您的服务器上的什么位置?目录结构和你本地的开发环境一样吗?您是使用composer 安装它还是只是复制粘贴?
  • 模块 --> D8 模块 ??这是我的自定义模块。我正在使用 redhat 服务器。

标签: php reflection redhat drupal-8


【解决方案1】:

在 src 下使用创建的控制器的最佳方式,例如 (modules/yourmodule/src/Controller/xyzController.php)。

路由路径将是:

yourmodule.payrs:
  path: '/thank-you'
  defaults:
    _title: 'Thank You'
    _controller: '\Drupal\yourmodule\Controller\xyzController::abc'
  requirements: 
    _permission: 'access content'
  options:
    no_cache: 'TRUE'

祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 2021-07-21
    • 1970-01-01
    • 2017-12-21
    • 1970-01-01
    • 2021-05-13
    • 1970-01-01
    相关资源
    最近更新 更多