2

Hi i have problem with ZF2,

when trying to access at public/index from the browser i got this Fatal Error from Server:

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

I already update the composer.json from:

{
    "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.*"
    }
}

to:

{
    "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.*"
    }
}

Also on init_autoloader.php i added this lines:

 require $zf2Path . '/Zend/Stdlib/compatibility/autoload.php';
 require $zf2Path . '/Zend/Session/compatibility/autoload.php';

and this how init_autoloader looks like:

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

Besides all the changes mentioned above, i still receive the getting the same error. By the way this is my PHP Versió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
4
  • There is a closed issue on Github from Feb 2013. It points exactly same situation and seems related with composer autoloading process. github.com/zendframework/ZFTool/issues/26 Commented Oct 18, 2014 at 7:02
  • 1
    This is the error you get if you try and run ZF 2.3 on too old a PHP version. After updating composer.json to drop it back to 2.2 are you sure you ran composer update? Check Zend\Version\Version.php to see what version you have. Commented Oct 18, 2014 at 12:23
  • 1
    as @TimFountain said. Minimum required PHP Version for 2.3.* is >=5.3.23. So either update your PHP Environment of you have to go with ZF 2.2.* Commented Oct 18, 2014 at 16:05
  • Problem solved. @TimFountain, indeed i made a self-updated to the composer, but on Zend\Version\Version.php the version still the same: const VERSION = '2.3.1'. What i had to do is to download a latest zendframework again, edit the composer.json to a previous 2.2.* ,and execute the self-update and install options. Commented Oct 18, 2014 at 18:08

2 Answers 2

1

I just moved to ZF 2.2 to fix

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

Edit composer.json by changing 2.3 to 2.2

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

Then php composer.phar update

Sign up to request clarification or add additional context in comments.

Comments

0

In doing software archaeology today, I ran into this issue with both "ZF 2.2.x" and "ZF 2.3.x". Taking a shot in the dark with "ZF 2.4.x" managed to resolve the issue.

My project's composer.json was modified to use this:

(...)
    "zendframework/zendframework": "2.4.*",
(...)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.