tzyganu / Magento2SampleModule

This is where I would put a Magento 2.0 Sample CRUD module if I had one.
MIT License
158 stars 65 forks source link

Error in Author Details Page #16

Open kevinjavitz opened 8 years ago

kevinjavitz commented 8 years ago

Running Mage 2.1.2 and php 7 author details page gives:

Fatal error: Cannot use Sample\News\Model\ImageFactory as ImageFactory because the name is already in use in /var/www/html/magento2/app/code/Sample/News/Helper/Image.php on line 26

ddoddsr commented 7 years ago

This is a bug in PHP when OPcache is not on. http://stackoverflow.com/questions/17746481/cannot-use-x-as-y-because-the-name-is-already-in-use-even-though-its-not/23879699#23879699

I am running php 5.6.30 via Xampp installed yesterday Feb 22 2017 I had the error on a clean Magento 2.1.5 turned on opcache in the php.ini file and no more error.

eddyonboard commented 7 years ago

The fix did not help me. Magento 2.1.5 Php 7.0.12 Opcache enabled.

This is what helped: In Sample/News/Helper/Image.php try change use Sample\News\Model\ImageFactory; to use Sample\News\Model\ImageFactory as MyImageFactory; and in constructor ImageFactory $imageFactory, to MyImageFactory$imageFactory,