不能使用 'Object 作为 class 名称,因为它是保留的 Cake 2.2.x

Cannot use 'Object as class name as it is reserved Cake 2.2.x

我在尝试设置我们拥有的站点的测试副本时遇到问题 运行,我在 Mint VM 下安装了文件和应用程序,当我将 apache 指向我得到的目录时500 错误和以下 -

[Thu Oct 25 15:09:39.714201 2018] [php7:error] [pid 8945] [client 192.168.0.14:52237] PHP Fatal error:  Cannot use 'Object' as class name as it is reserved in /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/Object.php on line 30
[Thu Oct 25 15:09:39.714547 2018] [php7:error] [pid 8945] [client 192.168.0.14:52237] PHP Fatal error:  Uncaught Error: Class 'Controller' not found in /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php:174\nStack trace:\n#0 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php(92): ExceptionRenderer->_getController(Object(InternalErrorException))\n#1 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ErrorHandler.php(126): ExceptionRenderer->__construct(Object(InternalErrorException))\n#2 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ErrorHandler.php(284): ErrorHandler::handleException(Object(InternalErrorException))\n#3 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ErrorHandler.php(213): ErrorHandler::handleFatalError(64, 'Cannot use 'Obj...', '/home/jamesmcgr...', 30)\n#4 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/App.php(933): ErrorHandler::handleError(64, 'Cannot use 'Obj...', '/home/jamesmcgr...', 30, Array)\n#5 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/App.php(906): App::_checkFatalError()\n#6 [internal function]: App::shutdow in /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php on line 174

奇怪的是我们直接从运行正常的网络服务器中提取了文件。第一个错误让我相信这是由于 php 或 apache 版本根据我在其他地方阅读的内容而不同(工作网络服务器是 7.1.10,测试服务器是 7.2.10,我不能确定网络服务器的 apache 版本 运行).

我不确定这两个错误是否相关,我还在适应这个环境,所以进展缓慢。

如有任何帮助,我们将不胜感激。

后一个错误是由导致前一个错误的问题引起的,前一个错误应该是不言而喻的,名称Object已保留,不能再用作class名称.

Object 已成为 PHP 7.2 中的硬保留名称,自 PHP 7.0 起被软保留。为了获得适当的 PHP 7.2 兼容性,请将您的 CakePHP 依赖项至少升级到最新的 2.10.x 版本。

如果您使用的是内置加密,则还必须切换到 OpenSSL(请参阅 Security.useOpenSsl 配置选项),或者如果您的应用使用的加密不兼容,通过 PECL 安装 Mcrypt,或使用像 phpseclib/mcrypt_compat.

这样的 polyfill

如果您此时无法升级 CakePHP,则必须将 PHP 安装降级到 7.1.x 或更早版本。

另见