LoginSignup
1
0

More than 5 years have passed since last update.

【Laravel4.2&Mac】$_ENVが空っぽで読めなくなった...。

Posted at

概要

Mac上でLaravel4.2のプロジェクトをクローンして

php artisan serve

でビルトインサーバしようとしたところ、

{"error":{"type":"ErrorException","message":"Undefined index: 〇〇","file":"path/to/app/config/app.php","line":20}}%

というエラーが出てきた。

プロジェクトは開発環境と本番環境用でそれぞれenvがあり、
bootstrap/start.phpでそれらを分けている状態でした。

$_ENVをvar_dumpしてみるとarray(0)と書いてあったので、そもそも読めてないみたいです。

解決?

を参考見てみたところ、
どうやらホスト名ベースの名前はUnix系のシステムでしか動作しないらしいので、
MacのPC名を調べ、bootstrap/start.phpへPC名の記述を追加したところ、
動作しました。

$ uname -n
MY_PC_NAME
env
$env = $app->detectEnvironment(array(

    'local' => array(...., 'MY_PC_NAME'),

まだまだLaravelの使い方がわかっていないので、
こういったenvのところで困らないようになりたいです...。

1
0
2

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
1
0