致命错误,ArrayObject :: offsetGet()必须与Linux上的Zend framework 2.3的ArrayAccess:offsetGet()兼容:Debian 2.6.32-46

时间:2014-10-18 02:22:43

标签: php zend-framework2 debian arrayobject

嗨我有ZF2的问题,

当尝试从浏览器访问public / index时,我从服务器获得了致命错误:

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';
    }
}

除了上面提到的所有更改,我仍然收到相同的错误。 顺便说一句,这是我的PHPVersión:

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

1 个答案:

答案 0 :(得分:0)

我刚搬到ZF 2.2来修复

Fatal error: Declaration of Zend\Stdlib\ArrayObject::offsetGet() must be compatible with that of ArrayAccess::offsetGet() in /path/application/vendor/zendframework/zendframework/library/Zend/Stdlib/ArrayObject.php on line 22

通过将2.3更改为2.2来编辑composer.json

"zendframework/zendframework": "2.2.*",

然后php composer.phar update