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 5 years have passed since last update.

VSCユーザーがLaravelのデータベース接続設定でエラーが出た時、確認すべきこと

Last updated at Posted at 2020-03-20

こんにちは!今回がエンジニア初学者がついうっかり詰まってしまった初歩的なエラーとその原因をご紹介していきたいと思います。

LaravelのDB接続設定エラー

入力した項目は合っているはずなのに、なぜかDB接続できない。

そんな時は、もう一度書き込んでいるファイルが正しいか確認してみてください!
もしかしたら.envファイルではなく.env.exampleに設定を書き込んでいるかもしれません。
DB接続設定を書き込むのは.envファイルです!

なぜこのエラーにハマったのか

原因は、普段使用しているVisualStudioCode(以下VSC)のクイックオープン(Cmd + P)でファイル検索をした時に、.envが引っ掛からず、ついうっかり検索結果に出ていた.env.exampleを私が.envだと誤認したからでした。

対応策

なぜ.envファイルが検索結果に出なかったのか。
それはVSCの設定で.ignoreファイルと.gitignoreファイルを検索対象から外すようにしていたからです。
検索対象に入れたい場合は、VSCの環境設定に入って検索ボックスからSearch:Use Ignore Filesを検索し、チェックを外しておくようにしましょう。
image.png

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?