This works fine for me...
In AppServiceProvider->boot():
\Config::set('world.name', 'Mundo Hurlingham');
And then in a controller method:
\Config::set('world.name', 'Test');
echo "Result: ".config('world.name').'.'; // displays "Result: Test."
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all,
I'm using the Config facade to set and use global variables on my site and it's working fine, but I have a problem.
On the AppServiceProvider.php (boot method) Im doing this:
$config->set('world.name', 'Mundo Hurlingham');
And then on a controller Im trying to overwrite the value doing this:
$config->set('world.name', 'Test');
echo "Result: ".config('world.name').'.';
But the problem is that the config('world.name') result is always "Mundo Hurlingham". And then I use the value on a view an is still the old value.
How can I overwrite the value? Is there a way to do this? Maybe clearing the cache or something like that?
Thanks in advance!
This works fine for me...
In AppServiceProvider->boot():
\Config::set('world.name', 'Mundo Hurlingham');
And then in a controller method:
\Config::set('world.name', 'Test');
echo "Result: ".config('world.name').'.'; // displays "Result: Test."
Please or to participate in this conversation.