LoginSignup
4
2

More than 1 year has passed since last update.

【エラー備忘録】LaravelでNamespace declaration statement has to be the very first statement or after any declare call in the script のエラー

Last updated at Posted at 2021-04-04

状況

Laravelでアプリケーションを作成中、localhostを立ち上げると次のようなエラーが出た。

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

原因

・namespaceの上に何も書いてはいけない
・<?php の上に何も書いてはいけない
ということのようだ。

エラーが指していたのは、Articleモデルである app/Article.php のファイル。

解決策

app/Article.php の <?php の上に、コメント化したメモを書いていた。
それを <?php の下に移動させてみると、正常に画面表示された。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2