cancel
Showing results for 
Search instead for 
Did you mean: 

Fatal error: Namespace declaration statement has to be the very first statement or after any declare

Fatal error: Namespace declaration statement has to be the very first statement or after any declare

Why I ma getting this error and how can I resolve it ?

Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in C:\xampp\htdocs\magento2\vendor\magento\framework\View\Element\Template\File\Validator.php on line 6

3 REPLIES 3

Re: Fatal error: Namespace declaration statement has to be the very first statement or after any dec

Hello @testnathco5024 

 

In php syntax, You should use namespace in the first line.


Can you just open that file and check namespace [PHP_CLASS_PATH];

 

It should be right after the <?php tag starting.

 

Hope it helps.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Fatal error: Namespace declaration statement has to be the very first statement or after any dec

Ensure that your code starts like - 

 

<?php
namespace Vendor\Module\Folder\Folder;

Re: Fatal error: Namespace declaration statement has to be the very first statement or after any dec

still the error is there in mine