cancel
Showing results for 
Search instead for 
Did you mean: 

Deprecated: The each() function is deprecated.

Deprecated: The each() function is deprecated.

Following error showing while installing Magento-CE-2.2.1-2017-11-03-05-16-17
PHP Version : ea-php72


Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/username/public_html/vendor/colinmollenhour/cache-backend-file/File.php on line 81

Fatal error: Uncaught Zend\Stdlib\Exception\RuntimeException: No wrapper found supporting "UTF-8" in /home/username/public_html/vendor/zendframework/zend-stdlib/src/StringUtils.php:135 Stack trace: #0 /home/username/public_html/vendor/zendframework/zend-validator/src/Hostname.php(2034): Zend\Stdlib\StringUtils::getWrapper('UTF-8') #1 /home/username/public_html/vendor/zendframework/zend-http/src/PhpEnvironment/Request.php(285): Zend\Validator\Hostname->isValid('usernamesp...') #2 /home/username/public_html/vendor/zendframework/zend-http/src/PhpEnvironment/Request.php(84): Zend\Http\PhpEnvironment\Request->setServer(Object(Zend\Stdlib\Parameters)) #3 /home/username/public_html/vendor/magento/framework/HTTP/PhpEnvironment/Request.php(133): Zend\Http\PhpEnvironment\Request->__construct() #4 /home/username/public_html/vendor/magento/framework/App/Request/Http.php(115): Magento\Framework\HTTP\PhpEnvironment\Request->__construct(Object(Magento\Framework\Stdlib\Cookie\PhpCookieReader), Object(Ma in /home/username/public_html/vendor/zendframework/zend-stdlib/src/StringUtils.php on line 135

13 REPLIES 13

Re: Deprecated: The each() function is deprecated.

Magento is not officially compatible with PHP 7.2. See http://devdocs.magento.com/guides/v2.1/install-gde/system-requirements-tech.html

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Deprecated: The each() function is deprecated.

Hi @Tom Robertshaw

 

I can see you're a moderator so maybe you might know a little more about the development of Magento. My question to Magento developers is, Why till now, even in/with Magento 2, it takes so much server side commands to set up or install and run Magento? Compare to many other CMS' or even eCommerce platforms, they are more like just plug and play when it comes to the platforms themselves. Of course there always more work to do to make platform work or run applications, but Magento 2 itself requires too much work to just set up or install. 

Re: Deprecated: The each() function is deprecated.

@rapidweb That's a hard one to boil down into a single, comprehensive answer. And one I can only give my opinion on as I don't work for Magento. 

 

Some command line commands are generic to the PHP community which we didn't have for Magento 1 as it wasn't around at the time that was built. Nowadays, it's pretty standard approach to manage dependencies but definitely adds complexity. 

 

Some of the other commands are Magento specific. Many of these are due to Magento wanting to be highly extensible. The ability to have any section of code rewritten by extensions with fewer conflict risks than Magento 1 comes at a usability and ease of development cost. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Deprecated: The each() function is deprecated.

I have same issue on localhost issue has been resolved
PHP VERSION ISSUE : change 7.2.4 to 7.1.6 this may help to others.

Re: Deprecated: The each() function is deprecated.

We changed the PHP version to 7.0.6 in WAMP server and the problem is solved,that's all  !!. Thank you.

Re: Deprecated: The each() function is deprecated.

How ? I also face same issue i don't know how to resolve it .can you inform me?

Re: Deprecated: The each() function is deprecated.

When I changed the version of PHP it worked.

Thanks!!

Re: Deprecated: The each() function is deprecated.

Hi,

 

I face the same issue on Magento2.6 in couple of files during execution of bin/magento commands.

each is deprecated in PHP on PHP 7.2 & so It will not work on advance PHP 7.1 versions.

 

So, either you step down to PHP version to 7.0 or early version of 7.1 or modify the code.

I do modifications on following files:

- /vendor/colinmollenhour/cache-backend-file/File.php

at line 81 modify below code:

------------------------------------------------------------------------

while (list($name, $value) = each($options)) {
            $this->setOption($name, $value);
}

with:

foreach($options as $name=>$value){

      $this->setOption($name, $value);   

}

 

Do the same change on another file:

vendor/magento/zendframework1/library/Zend/Cache/Backend.php

on line no 79. modify below code:

----------------------------------------------------------

while (list($name, $value) = each($directives)) {
            if (!is_string($name)) {
                  Zend_Cache::throwException("Incorrect option name : $name");
              }
              $name = strtolower($name);
              if (array_key_exists($name, $this->_directives)) {
                  $this->_directives[$name] = $value;
              }
        }

With:

 

foreach ($directives as $name => $value ) {
            if (!is_string($name)) {
                  Zend_Cache::throwException("Incorrect option name : $name");
              }
              $name = strtolower($name);
              if (array_key_exists($name, $this->_directives)) {
                  $this->_directives[$name] = $value;
              }
        }

 

 

 

Re: Deprecated: The each() function is deprecated.

Thank you for this solution. It works.. Thanks Again