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

2 REPLIES 2
Highlighted

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 "Accept as Solution"
Highlighted

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;