【问题标题】:Laravel config/app.php not updatingLaravel config/app.php 没有更新
【发布时间】:2020-01-11 02:10:54
【问题描述】:

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

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

即使 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 [▶]]

一些提示将不胜感激。

【问题讨论】:

  • php artisan config:clear清除了配置缓存?
  • @Simon Svensson tnx。在你提到它之前得到了答案。 Tnx

标签: laravel laravel-5 configuration-files


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    对此只是一个小小的补充说明。如果您在 localhost:8000php artisan serve 上运行本地服务器,并且您对 .env 文件或配置文件进行了更改,即使在使用已接受答案中的步骤清除配置缓存后,它也不会更新.

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

    【讨论】:

    • 我从来没有考虑过。这不仅解决了这个问题,甚至解决了其他配置。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2023-01-30
    • 2015-09-22
    • 2016-07-09
    • 2020-08-26
    • 1970-01-01
    • 2020-07-16
    • 1970-01-01
    • 2017-10-02
    相关资源
    最近更新 更多