In magento2 some times you may get following error message in log file. FastCGI sent in stderr: “PHP message: PHP Fatal error: Cannot declare class Namespace\Mymodule\Helper\Data because the name is already in use in Namespace/Mymodule/Helper/Data.php on line 10” while reading response header from upstream
Mean – You have used/declared Same class name for two different helper class in a file.
Ex: Actual Code:
namespace Namespace\Mymodule\Helper; use Namespace\Mymodule1\Helper\Data class Data extends \Magento\Framework\App\Helper\AbstractHelper { public function __construct( Data $mymodule1helper ) { parent::__construct($context); } }
Change it to as like below
namespace Namespace\Mymodule\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { public function __construct( Namespace\Mymodule1\Helper\Data $mymodule1helper ) { parent::__construct($context); } }
I have used same class name for two different module Helper class (Data.php) in inside __construct().
To resolve this issue declare full class path from __construct.