【问题标题】:beberlei DoctrineExtensions in ZF2 working fine on Windows localhost but shows fatal error Linux production serverZF2 中的 beberlei DoctrineExtensions 在 Windows localhost 上运行良好,但显示致命错误 Linux 生产服务器
【发布时间】:2017-05-23 19:35:58
【问题描述】:

我想在 ZF2 中使用 DoctrineExtensions 的 Day、Week、Month 和 Year 函数,并收到以下错误消息。该代码在我在 Windows 上运行的本地机器上运行良好,但相同的代码在 Linux 上运行的服务器上无法运行。

Fatal error: Uncaught Error: Class 'DoctrineExtensions\Query\Mysql\Day' not found

这是我的 module.config.php 配置

'configuration' => array(
        'orm_default' => array(
            'datetime_functions' => array(
                'day' => 'DoctrineExtensions\Query\MySql\Day',
                'week' => 'DoctrineExtensions\Query\MySql\Week',
                'month' => 'DoctrineExtensions\Query\MySql\Month',
                'Year' => 'DoctrineExtensions\Query\MySql\Year',
            ),
            'string_functions'   => array(),
        )
    ),

我使用 composer 安装了模块。

【问题讨论】:

  • 我建议通过 ::class (php.net/manual/en/…) 使用类名称解析,以减少代码中“魔术”字符串的数量,并且作为奖励,您的 IDE(如果您使用的话)将提示该类是否存在。 \DoctrineExtensions\Query\MySql\Day::class 而不是 'DoctrineExtensions\Query\MySql\Day'
  • 如果包含该类的文件存在,您能否检查服务器的供应商文件夹? find . -name "DoctrineExtensions*" 应该会告诉你是否存在依赖项。

标签: doctrine-orm zend-framework2 doctrine-extensions


【解决方案1】:

“DoctrineExtensions\Query\MySql\”应该是“DoctrineExtensions\Query\Mysql\”,带有小“s”而不是大写“S”。 Linux 区分大小写,这就是它找不到类路径的原因。我有同样的问题,这就是我们解决它的方法。希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 2018-02-09
    • 1970-01-01
    • 1970-01-01
    • 2021-10-03
    • 1970-01-01
    • 2021-09-28
    相关资源
    最近更新 更多