问题
I'm having an issue trying to set up a testing copy of a site we have running, I have the files and applications installed under a Mint VM and when I point apache at the directory I get a 500 error and the following-
[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
The weird thing is we've ripped the files straight from the webserver, which is functioning correctly. The first error makes me believe that it's due to the php or apache versions being different based on what I've read elsewhere (the working webserver is 7.1.10 and the testing one is 7.2.10, I can't determine what version of apache the webserver is running).
I'm not sure if the two errors are related, I'm still getting used to this environment so progress is slow picking up this stuff.
Any help at all would be greatly appreciated.
回答1:
The latter error is caused by the problem that causes former error, and the former error should be rather self-explantory, the name Object
is reserved and cannot be used as class name anymore. For proper PHP 7.2 compatibility, upgrade your CakePHP dependency to the latest 2.10.x
release.
If you are using the built-in encryption, you'll also have to either switch to OpenSSL (see the Security.useOpenSsl
configuration option), or if the encryption that your app is using isn't compatible, install Mcrypt via PECL, or use a polyfill like phpseclib/mcrypt_compat.
If you cannot upgrade CakePHP at this moment, then you'll have to downgrade your PHP installation.
See also
- https://github.com/cakephp/cakephp/issues/11346
- Cookbook > Core Libraries > Utilities > Security
- Cookbook > Appendices > Migration Guides
- PHP Manual > Appendices > Migrating from PHP 7.1.x to PHP 7.2.x > Backward incompatible changes > object for class names
- PHP Manual > Appendices > Migrating from PHP 7.1.x to PHP 7.2.x > Other changes > Moving MCrypt to PECL
来源:https://stackoverflow.com/questions/52981403/cannot-use-object-as-class-name-as-it-is-reserved-cake-2-2-x