0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Laravel】エラー対処法。'parse': 767: unexpected token at ''

Posted at

Dockerを使って起動したLaravelのプロジェクトで以下エラーが出た場合の対処法について。

ネットで検索するとエラーが発生する条件がいろいろあるようなので、次の状況の場合の解決法。

発生状況

プロジェクトはAPIを利用しており、APIから取得したデータを表示するページでエラーが発生。

プロジェクトトップは正常に表示されているが、特定のページを開くと404になる。

dd関数(またはdump関数)でデバッグすると以下が表示される。

Traceback: `parse': 767: unexpected token at ''

APIにアクセスするための暗号(トークン)が違う。というエラー。


## 発生原因 APIを提供しているサーバーの環境環境が変わり、それに伴って環境変数(.env)が変化していたが、アップデートをしていなかった。

このため、APIにはアクセスできていたが、欲しいデータにアクセスできなかった。


## 対処法 APIを提供しているサーバーのデータをgit pullしてアップデート。

今回の対象はサブモジュールで扱っているファイルだったため、submodule updateで更新。(親のレポジトリを更新するだけではsubmoduelは更新されない)


## .envファイル更新時の注意点 ### 1. 置き場所はルートディレクトリ プロジェクトのルートディレクトリ以外の場所で更新した場合は、ルートディレクトリにコピーする必要がある。
### 2. 独自の環境変数を消さないように 自分専用の環境変数を使っていた場合、上書きすると消えてしまうので注意。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?