嗨,我对 ZF2 有疑问,
当尝试从浏览器访问公共/索引时,我从服务器收到此致命错误:
PHP Fatal error: Declaration of Zend\\Stdlib\\ArrayObject::offsetGet() must be compatible with that of ArrayAccess::offsetGet() in /var/www/somevirtualhost/vendor/zendframework/zendframework/library/Zend/Stdlib/ArrayObject.php on line 23
我已经从以下位置更新了 composer.json:
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.3.*"
}
}
至:
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.*"
}
}
同样在 init_autoloader.php 我添加了这一行:
require $zf2Path . '/Zend/Stdlib/compatibility/autoload.php';
require $zf2Path . '/Zend/Session/compatibility/autoload.php';
这就是 init_autoloader 的样子:
if ($zf2Path) {
if (isset($loader)) {
$loader->add('Zend', $zf2Path);
$loader->add('ZendXml', $zf2Path);
} else {
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
Zend\Loader\AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' => array(
'autoregister_zf' => true
)
));
//Fix for PHP 5.3.3
require $zf2Path . '/Zend/Stdlib/compatibility/autoload.php';
require $zf2Path . '/Zend/Session/compatibility/autoload.php';
}
}
除了上述所有更改之外,我仍然收到相同的错误。顺便说一下,这是我的 PHP 版本:
PHP 5.3.3-7+squeeze19 with Suhosin-Patch (cli) (built: Feb 18 2014 13:59:15)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH