laravel error : Namespace declaration statement has to be the very first statement or after any declare call in the script

Viewed 31915

After I pull my project in git, I get this error. It's my 1st time to encounter this error.

The error is:

Namespace declaration statement has to be the very first statement or after any declare call in the script.

my Model

 <?php
 
namespace App\Models;

The version of my Laravel is 5.5.

3 Answers

There is an empty space before the <?php tag. Remove it.

<?php

namespace App\Models;

If problem continue you have to remove bom from file via notepad++

Also check that your IDE create UTF-8 files (with NO BOM) UTF-8 BOM. For example, in phpStorm Settings / Editor / File Encodings -> Create UTF-8 files: with NO BOM

Related