简体   繁体   中英

Laravel 4 Config::get() returns null

I am using laravel 4 and I have created a file inside app/config as follows : The file name is aws.php

<?php

return [


    'key' => 'xyz',
];

Now, from my controller I tried to access the key as follows :

$key = Config::get('aws.key');

but it returns null. How can I solve this problem ? I have googled it but have not found the solution.

You can access "key" by Config::get('aws.key'); but need to run this command: php artisan config:clear

try

$key = \Config::get('aws.key');

Config is not in the same namespace as class that call this facade, so You want to go to global namespace to search Config class

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM