Use \Config::get('app.env');
instead of env(APP_ENV);
because you're going to get the same error eventually and that's not good for a live website.
If you want to add custom variables from your ENV, go into your config app and find this:
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
add a new line under "'env' => env('APP_ENV', 'production'),
", so for example, it could be the following:
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
'key' => env('APP_KEY'),
You can call the "key" variable like this:
\Config::get('app.key');
Whenever you add a new variable like "key" to the app env, you'll need to use config:cache
to reset the cache.