Laravel 5.3 - env() always returns null
up vote
12
down vote
favorite
I try to find out why my env()
helper always returns null
. This causes trouble especially in app.php
file, where are env()
helpers widely used by default. Perhaps any mysterious server setting?
My env file:
APP_ENV=production
APP_KEY=base64:mymagickey=
APP_DEBUG=false
APP_LOG_LEVEL=info
APP_URL=http://www.example.com
etc...
EDIT - I tried following:
php artisan cache:clear
php artisan view:clear
php artisan config:cache
and ofcourse, i am using env
helper like this: env('APP_ENV')
But still no success. The wierd part is, that $_ENV
php variable contains every single variable from .env
file.
php laravel-5 environment-variables
add a comment |
up vote
12
down vote
favorite
I try to find out why my env()
helper always returns null
. This causes trouble especially in app.php
file, where are env()
helpers widely used by default. Perhaps any mysterious server setting?
My env file:
APP_ENV=production
APP_KEY=base64:mymagickey=
APP_DEBUG=false
APP_LOG_LEVEL=info
APP_URL=http://www.example.com
etc...
EDIT - I tried following:
php artisan cache:clear
php artisan view:clear
php artisan config:cache
and ofcourse, i am using env
helper like this: env('APP_ENV')
But still no success. The wierd part is, that $_ENV
php variable contains every single variable from .env
file.
php laravel-5 environment-variables
1
have you tried to check the values via tinker ? also which version of Laravel 5 you are using ? the latest one is5.4.17
as I remember, so what is your latest versoin
– Zaher
Apr 6 '17 at 11:20
add a comment |
up vote
12
down vote
favorite
up vote
12
down vote
favorite
I try to find out why my env()
helper always returns null
. This causes trouble especially in app.php
file, where are env()
helpers widely used by default. Perhaps any mysterious server setting?
My env file:
APP_ENV=production
APP_KEY=base64:mymagickey=
APP_DEBUG=false
APP_LOG_LEVEL=info
APP_URL=http://www.example.com
etc...
EDIT - I tried following:
php artisan cache:clear
php artisan view:clear
php artisan config:cache
and ofcourse, i am using env
helper like this: env('APP_ENV')
But still no success. The wierd part is, that $_ENV
php variable contains every single variable from .env
file.
php laravel-5 environment-variables
I try to find out why my env()
helper always returns null
. This causes trouble especially in app.php
file, where are env()
helpers widely used by default. Perhaps any mysterious server setting?
My env file:
APP_ENV=production
APP_KEY=base64:mymagickey=
APP_DEBUG=false
APP_LOG_LEVEL=info
APP_URL=http://www.example.com
etc...
EDIT - I tried following:
php artisan cache:clear
php artisan view:clear
php artisan config:cache
and ofcourse, i am using env
helper like this: env('APP_ENV')
But still no success. The wierd part is, that $_ENV
php variable contains every single variable from .env
file.
php laravel-5 environment-variables
php laravel-5 environment-variables
edited Apr 6 '17 at 11:43
asked Apr 6 '17 at 0:27
Fusion
1,12721529
1,12721529
1
have you tried to check the values via tinker ? also which version of Laravel 5 you are using ? the latest one is5.4.17
as I remember, so what is your latest versoin
– Zaher
Apr 6 '17 at 11:20
add a comment |
1
have you tried to check the values via tinker ? also which version of Laravel 5 you are using ? the latest one is5.4.17
as I remember, so what is your latest versoin
– Zaher
Apr 6 '17 at 11:20
1
1
have you tried to check the values via tinker ? also which version of Laravel 5 you are using ? the latest one is
5.4.17
as I remember, so what is your latest versoin– Zaher
Apr 6 '17 at 11:20
have you tried to check the values via tinker ? also which version of Laravel 5 you are using ? the latest one is
5.4.17
as I remember, so what is your latest versoin– Zaher
Apr 6 '17 at 11:20
add a comment |
6 Answers
6
active
oldest
votes
up vote
23
down vote
Hope this command will save you
php artisan config:clear
add a comment |
up vote
5
down vote
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.
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
add a comment |
up vote
3
down vote
It is a ".env" known bug which can be solved with:
php artisan config:cache
9
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
5
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
2
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
add a comment |
up vote
0
down vote
accepted
Looks like there was installed old PHP version on server, which is not situable for Laravel's .env
package to run properly. When I deployed website into a different server with PHP 7 installed, env()
returned values as expected.
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
add a comment |
up vote
0
down vote
env(...)
function will not work after you cached the config. (starting from laravel 5.2 till current 5.7)
The documentation says
If you are using the
config:cache
command during deployment, you must make sure that you are only calling theenv
function from within your configuration files, and not from anywhere else in your application.
So the correct answer would be to
If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.
And I quoted it from the same documentation
But for a quick fix this will do:
php artisan config:clear
And now it should be clear why, when you tried config:cache
it did not help, even though it clears the config prior to caching.
add a comment |
up vote
0
down vote
Five most important commands if your Laravel is not working as expected after some modifications in .env or database folder or because of any other modifications.
Here is full explanation:
https://www.youtube.com/watch?v=Q1ynDMC8UGg
php artisan config:clear
php artisan cache:clear
composer dump-autoload
php artisan view:clear
php artisan route:clear
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
1
running onlyphp artisan config:cache
does not work. After i runphp artisan config:clear
it works. Now I can use again env($key). Thx @Learner
– calin24
Oct 8 at 8:46
I am glad it worked.
– Learner
Oct 8 at 10:01
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
add a comment |
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
23
down vote
Hope this command will save you
php artisan config:clear
add a comment |
up vote
23
down vote
Hope this command will save you
php artisan config:clear
add a comment |
up vote
23
down vote
up vote
23
down vote
Hope this command will save you
php artisan config:clear
Hope this command will save you
php artisan config:clear
answered Apr 26 at 7:44
sh6210
65349
65349
add a comment |
add a comment |
up vote
5
down vote
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.
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
add a comment |
up vote
5
down vote
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.
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
add a comment |
up vote
5
down vote
up vote
5
down vote
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.
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.
answered Jul 10 '17 at 8:10
rebirth1078
12719
12719
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
add a comment |
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
I am not sure but may be this bug only occurs in windows. but your solution resolved it in windows too. will it work in linux production environment?
– Amit Shah
Sep 17 at 9:44
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
@AmitShah, it is not a bug, it is a feature. Please check out my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:38
add a comment |
up vote
3
down vote
It is a ".env" known bug which can be solved with:
php artisan config:cache
9
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
5
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
2
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
add a comment |
up vote
3
down vote
It is a ".env" known bug which can be solved with:
php artisan config:cache
9
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
5
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
2
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
add a comment |
up vote
3
down vote
up vote
3
down vote
It is a ".env" known bug which can be solved with:
php artisan config:cache
It is a ".env" known bug which can be solved with:
php artisan config:cache
answered Apr 6 '17 at 0:31
vpdeva
144110
144110
9
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
5
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
2
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
add a comment |
9
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
5
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
2
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
9
9
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
Some users may need to do php artisan config:clear instead
– rebirth1078
Jul 11 '17 at 15:02
5
5
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
Laravel 5.5 I had to run 'php artisan config:clear'. Thanks
– dacastro4
Oct 24 '17 at 16:18
2
2
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
php artisan config:cache is the reason why env() values are null. If you wish to cache your config and env vars then you shouldn't use env() anywhere else except config files because once cached env() will always return null. Although now I am also seeing config() and Config::get() helper return null after caching which is weird too.
– BRBdot
Jul 26 at 14:40
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
follow up to above - ...So thats when you should realize that config() helper cannot directly access values in .env either. You will need to create or use existing config/<insert config file name>.php config file and create your config entry from .env and then use that mapped value.
– BRBdot
Jul 26 at 16:33
add a comment |
up vote
0
down vote
accepted
Looks like there was installed old PHP version on server, which is not situable for Laravel's .env
package to run properly. When I deployed website into a different server with PHP 7 installed, env()
returned values as expected.
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
add a comment |
up vote
0
down vote
accepted
Looks like there was installed old PHP version on server, which is not situable for Laravel's .env
package to run properly. When I deployed website into a different server with PHP 7 installed, env()
returned values as expected.
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Looks like there was installed old PHP version on server, which is not situable for Laravel's .env
package to run properly. When I deployed website into a different server with PHP 7 installed, env()
returned values as expected.
Looks like there was installed old PHP version on server, which is not situable for Laravel's .env
package to run properly. When I deployed website into a different server with PHP 7 installed, env()
returned values as expected.
edited Nov 15 at 12:07
answered Apr 12 '17 at 15:17
Fusion
1,12721529
1,12721529
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
add a comment |
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
It is not about php version, it is about deployment scripts, please see my answer for details.
– Yevgeniy Afanasyev
Nov 20 at 2:36
add a comment |
up vote
0
down vote
env(...)
function will not work after you cached the config. (starting from laravel 5.2 till current 5.7)
The documentation says
If you are using the
config:cache
command during deployment, you must make sure that you are only calling theenv
function from within your configuration files, and not from anywhere else in your application.
So the correct answer would be to
If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.
And I quoted it from the same documentation
But for a quick fix this will do:
php artisan config:clear
And now it should be clear why, when you tried config:cache
it did not help, even though it clears the config prior to caching.
add a comment |
up vote
0
down vote
env(...)
function will not work after you cached the config. (starting from laravel 5.2 till current 5.7)
The documentation says
If you are using the
config:cache
command during deployment, you must make sure that you are only calling theenv
function from within your configuration files, and not from anywhere else in your application.
So the correct answer would be to
If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.
And I quoted it from the same documentation
But for a quick fix this will do:
php artisan config:clear
And now it should be clear why, when you tried config:cache
it did not help, even though it clears the config prior to caching.
add a comment |
up vote
0
down vote
up vote
0
down vote
env(...)
function will not work after you cached the config. (starting from laravel 5.2 till current 5.7)
The documentation says
If you are using the
config:cache
command during deployment, you must make sure that you are only calling theenv
function from within your configuration files, and not from anywhere else in your application.
So the correct answer would be to
If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.
And I quoted it from the same documentation
But for a quick fix this will do:
php artisan config:clear
And now it should be clear why, when you tried config:cache
it did not help, even though it clears the config prior to caching.
env(...)
function will not work after you cached the config. (starting from laravel 5.2 till current 5.7)
The documentation says
If you are using the
config:cache
command during deployment, you must make sure that you are only calling theenv
function from within your configuration files, and not from anywhere else in your application.
So the correct answer would be to
If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.
And I quoted it from the same documentation
But for a quick fix this will do:
php artisan config:clear
And now it should be clear why, when you tried config:cache
it did not help, even though it clears the config prior to caching.
answered Nov 20 at 2:32
Yevgeniy Afanasyev
7,63544264
7,63544264
add a comment |
add a comment |
up vote
0
down vote
Five most important commands if your Laravel is not working as expected after some modifications in .env or database folder or because of any other modifications.
Here is full explanation:
https://www.youtube.com/watch?v=Q1ynDMC8UGg
php artisan config:clear
php artisan cache:clear
composer dump-autoload
php artisan view:clear
php artisan route:clear
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
1
running onlyphp artisan config:cache
does not work. After i runphp artisan config:clear
it works. Now I can use again env($key). Thx @Learner
– calin24
Oct 8 at 8:46
I am glad it worked.
– Learner
Oct 8 at 10:01
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
add a comment |
up vote
0
down vote
Five most important commands if your Laravel is not working as expected after some modifications in .env or database folder or because of any other modifications.
Here is full explanation:
https://www.youtube.com/watch?v=Q1ynDMC8UGg
php artisan config:clear
php artisan cache:clear
composer dump-autoload
php artisan view:clear
php artisan route:clear
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
1
running onlyphp artisan config:cache
does not work. After i runphp artisan config:clear
it works. Now I can use again env($key). Thx @Learner
– calin24
Oct 8 at 8:46
I am glad it worked.
– Learner
Oct 8 at 10:01
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
add a comment |
up vote
0
down vote
up vote
0
down vote
Five most important commands if your Laravel is not working as expected after some modifications in .env or database folder or because of any other modifications.
Here is full explanation:
https://www.youtube.com/watch?v=Q1ynDMC8UGg
php artisan config:clear
php artisan cache:clear
composer dump-autoload
php artisan view:clear
php artisan route:clear
Five most important commands if your Laravel is not working as expected after some modifications in .env or database folder or because of any other modifications.
Here is full explanation:
https://www.youtube.com/watch?v=Q1ynDMC8UGg
php artisan config:clear
php artisan cache:clear
composer dump-autoload
php artisan view:clear
php artisan route:clear
edited 2 days ago
answered Apr 6 '17 at 5:21
Learner
3,35611432
3,35611432
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
1
running onlyphp artisan config:cache
does not work. After i runphp artisan config:clear
it works. Now I can use again env($key). Thx @Learner
– calin24
Oct 8 at 8:46
I am glad it worked.
– Learner
Oct 8 at 10:01
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
add a comment |
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
1
running onlyphp artisan config:cache
does not work. After i runphp artisan config:clear
it works. Now I can use again env($key). Thx @Learner
– calin24
Oct 8 at 8:46
I am glad it worked.
– Learner
Oct 8 at 10:01
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
the same problem here....not working env(). I have tried remove cache, composer dump-autoload....etc. I am using laravel 5.5.44 and I have to call the config from .env file with Config::get()
– calin24
Oct 8 at 7:08
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
I have listed all commands at one place you need to run in order to eliminate any kind of cache issue with env file or config etc. Here is the thread: stackoverflow.com/a/43041479/6935763 Please run all of them and let me know if it still doesn't work.
– Learner
Oct 8 at 7:47
1
1
running only
php artisan config:cache
does not work. After i run php artisan config:clear
it works. Now I can use again env($key). Thx @Learner– calin24
Oct 8 at 8:46
running only
php artisan config:cache
does not work. After i run php artisan config:clear
it works. Now I can use again env($key). Thx @Learner– calin24
Oct 8 at 8:46
I am glad it worked.
– Learner
Oct 8 at 10:01
I am glad it worked.
– Learner
Oct 8 at 10:01
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
I read your discussion and put my explanation in the separate answer, please check it out.
– Yevgeniy Afanasyev
Nov 20 at 2:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43243732%2flaravel-5-3-env-always-returns-null%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
have you tried to check the values via tinker ? also which version of Laravel 5 you are using ? the latest one is
5.4.17
as I remember, so what is your latest versoin– Zaher
Apr 6 '17 at 11:20