Laravel config/app.php 未更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32586524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:20:59  来源:igfitidea点击:

Laravel config/app.php not updating

laravellaravel-5configuration-files

提问by Mehrdad Shokri

in laravel 5 , config/app.php I've set the locale to 'ar' but while trying to get locale in code via: config('app.locale');

在 laravel 5 中, config/app.php 我已将语言环境设置为 'ar' 但同时尝试通过以下方式在代码中获取语言环境: config('app.locale');

I still get 'en'. Seems like config/app.php isn't auto-loaded/updated.

我仍然得到'en'。好像 config/app.php 没有自动加载/更新。

even if config/app.php is empty, executingconfig('app');returns:

即使 config/app.php 为空,执行也会config('app');返回:

array:10 [▼
"debug" => true
"url" => "http://localhost"
"timezone" => "UTC"
"locale" => "en"
"fallback_locale" => "en"
"key" => "XXXXXXXXXXXXXXXXXXXXXXX" // changed here
"cipher" => "AES-256-CBC"
"log" => "single"
"providers" => array:31 [?]
"aliases" => array:36 [?]]

Some hint will be appreciated.

一些提示将不胜感激。

回答by Mehrdad Shokri

Seems like configuration settings were cached. use php artisan config:clear

好像配置设置被缓存了。用php artisan config:clear

回答by raffjones

Just a minor additional note to this. If you are running a local server on localhost:8000with php artisan serveand you make changes to either your .envfile or in config files, even after clearing the config cache with the steps in the accepted answer, it doesn't update.

只是一个小的附加说明。如果你正在运行在本地服务器上localhost:8000使用php artisan serve,并您更改或者您的.env文件或配置文件,甚至是清除在接受答案的步骤配置缓存后,它不会更新。

You need to stop the local server (control + c in Terminal) and run php artisan serveto start it again - then your changes get picked up.

您需要停止本地服务器(终端中的 control + c)并运行php artisan serve以再次启动它 - 然后您的更改会被接收。