【问题标题】:How to undo the effect of command "php artisan config:cache"?如何撤消命令“php artisan config:cache”的效果?
【发布时间】:2019-06-10 09:02:48
【问题描述】:

我(错误地)在我的本地开发设置中运行命令 php artisan config:cache,因此所有调用(来自我的控制器)对 .env 文件(如 $_ENV['APP_ENV']$_ENV['ELS_INDEX'] 等)会导致以下结果错误:

MainController.php 第 470 行出现 ErrorException
未定义索引:APP_ENV

这是Configuration Caching的链接

请帮我纠正这个问题。提前致谢。

【问题讨论】:

    标签: php laravel configuration


    【解决方案1】:

    要么运行

    php artisan config:clear
    

    或从您的 Laravel 项目中删除文件 /bootstrap/cache/config.php

    (php artisan config:cache 创建/bootstrap/cache/config.php)

    【讨论】:

    • 谢谢,它解决了问题,但为什么 config.php 会干扰 .env 变量?
    • 比你 kerbholz - 你节省了我几个小时:-)。 @apprentice 来回答你的问题,这个文档 link 对我来说很有意义,在某种程度上它解决了你上面的问题。
    • 在 config:clear 之后再次运行 php artisan config:cache 就好了
    • @MHFuad True 用于生产站点。如果您需要大量调整设置,我不建议您在开发/本地环境中缓存您的配置
    • @MHFuad 和php artisan config:cache 已经预先清除了配置缓存
    猜你喜欢
    • 2016-06-21
    • 2019-04-13
    • 2015-04-17
    • 2020-01-03
    • 2018-02-16
    • 2021-01-13
    • 2014-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多