I have a constants file located in \\config\\constants.php
and it's an array of all the constants I am using in my project.
Sample declaration of the array in the file:
return [
'contant_1' => [
'value_1' => 'a',
'value_2' => 'b',
'value_3' => 'c'
],
'constant_2' => [
'value_1' => 'd',
'value_2' => 'e',
'value_3' => 'f'
],
'constant_3' => [
'value_1' => 'g',
'value_2' => 'h',
'value_3' => 'i'
], (...and so on)
];
note, this isn't the real value of the constants
So 'value_3' originally wasn't part of the array, and I included them and updated the array later on. I used php artisan config:clear
after the updated.
Now, I can access basically all the values of the constants, including the new 'value_3'
index, except for one constant. So for example I can get the value of 'constant_1' => 'value_3'
as well as 'constant_2' => 'value_3'
but for some reason, constant_3
does not have a 'value_3'
even though I included it.
When I try to print it on the console, it's blank. But for the rest of the constants in the array, they all have that 'value_3'
. I tried the php artisan config:clear
and php artisan config:cache
I also tried restarting my local server and still that 'constant_3'
doesn't have that 'value_3'
. I can even get the first 2 values of 'constant_3'
and it's weird that the 3rd one is just blank.
Please let me know what I'm doing wrong. I can't seem to find a similar problem anywhere. Thanks.
Try php artisan cache:clear
see if this works.
Edit: If its still not working try all clear commands and restart server.
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear
and restart server.
Try
php artisan config:cache
For clearing config cache.
What do you mean by "included them and updated the array later on" ? Don't include files manually in lavarel. If you need to update config values in runtime, use Config::set instead.
请尝试php artisan cache:clear
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.