Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Th3apprenTis's avatar

Using Laravel config files

This is embarrassing to say the least but somehow i am not able to all values in my config file

return [
    'banned_domains' => [
           'paypal.com',
           'amazon.com'
    ],
    'site_url' => 'http://test.com', //without trailing slash
    'ip_address_list' => [],
    'caching_enable' => true,
    'caching_time' => 1800,
    'hotness_no' => 5, // if an item is requested >= hotness_no in caching_time then its worth caching it
    'cacheable_content_types' => [
        'image/png',
        'image/jpeg',
        'image/jpg',
        'image/webp',
        'image/gif',
        'text/css'
    ],
    'parse_required_content_types' => [
        'text/html', 
        'text/css'
    ],  
];

If i do the following , i get the array as expected

dd(\Config::get('config.banned_domains'));

However this don't work

dd(\Config::get('config.caching_enable'));

0 likes
8 replies
bobbybouwmann's avatar

Have you cached your config? If that is the case you need to clear the cache first!

php artisan cache:clear

After that it should work as expected ;)

Tip: Never ever cache your config locally ;)

Th3apprenTis's avatar

It is still not working , is that any other cache i need to clear

dariohead's avatar

Maybe it's just dd() not printing true in a way that you can actually see it? Try dd(\Config::get('config.hotness_no'))to see if you get a 5?

Cronix's avatar

which config file? Where is it located and what is the filename?

\Config::get('config.banned_domains'))

That implies that you have a file named config.php, at /config/config.php. Is that correct? The first part of the key (before the first dot) refers to the name of the config file.

dariohead's avatar

Let's try to isolate the issue. Create a new config/test.php.

<?php
return [
    'test' => 123,
]

And then do dd(\Config::get('test.test'));. Are you seeing the expected 123?

Cronix's avatar

open a tinker session and just type config('config');

Does that give you your entire config array?

Personally I'd change the name to something other than just config. Maybe settings or something. I try to avoid naming things the same as the framework uses.

Th3apprenTis's avatar

I had to use php artisan config:cache to clear the cache

Please or to participate in this conversation.