<legend id='dG1g7'><style id='dG1g7'><dir id='dG1g7'><q id='dG1g7'></q></dir></style></legend>
        <tfoot id='dG1g7'></tfoot>
          <bdo id='dG1g7'></bdo><ul id='dG1g7'></ul>
        <i id='dG1g7'><tr id='dG1g7'><dt id='dG1g7'><q id='dG1g7'><span id='dG1g7'><b id='dG1g7'><form id='dG1g7'><ins id='dG1g7'></ins><ul id='dG1g7'></ul><sub id='dG1g7'></sub></form><legend id='dG1g7'></legend><bdo id='dG1g7'><pre id='dG1g7'><center id='dG1g7'></center></pre></bdo></b><th id='dG1g7'></th></span></q></dt></tr></i><div id='dG1g7'><tfoot id='dG1g7'></tfoot><dl id='dG1g7'><fieldset id='dG1g7'></fieldset></dl></div>

        <small id='dG1g7'></small><noframes id='dG1g7'>

        Laravel 5 - env() 总是返回 null

        Laravel 5 - env() always returns null(Laravel 5 - env() 总是返回 null)
        <legend id='BAt5c'><style id='BAt5c'><dir id='BAt5c'><q id='BAt5c'></q></dir></style></legend>
        <i id='BAt5c'><tr id='BAt5c'><dt id='BAt5c'><q id='BAt5c'><span id='BAt5c'><b id='BAt5c'><form id='BAt5c'><ins id='BAt5c'></ins><ul id='BAt5c'></ul><sub id='BAt5c'></sub></form><legend id='BAt5c'></legend><bdo id='BAt5c'><pre id='BAt5c'><center id='BAt5c'></center></pre></bdo></b><th id='BAt5c'></th></span></q></dt></tr></i><div id='BAt5c'><tfoot id='BAt5c'></tfoot><dl id='BAt5c'><fieldset id='BAt5c'></fieldset></dl></div>

              • <bdo id='BAt5c'></bdo><ul id='BAt5c'></ul>
                <tfoot id='BAt5c'></tfoot>

                    <tbody id='BAt5c'></tbody>

                  <small id='BAt5c'></small><noframes id='BAt5c'>

                • 本文介绍了Laravel 5 - env() 总是返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图找出为什么我的 env() 助手总是返回 null.这会导致麻烦,尤其是在 app.php 文件中,默认情况下广泛使用 env() 帮助程序.也许有什么神秘的服务器设置?

                  I try to find out why my env() helper always returns null. This causes trouble especially in app.php file, where are env() helpers widely used by default. Perhaps any mysterious server setting?

                  我的环境文件:

                  APP_ENV=production
                  APP_KEY=base64:mymagickey=
                  APP_DEBUG=false
                  APP_LOG_LEVEL=info
                  APP_URL=http://www.example.com
                  
                  etc...
                  

                  编辑 - 我尝试了以下:

                  php artisan cache:clear
                  php artisan view:clear
                  php artisan config:cache
                  

                  当然,我正在使用这样的 env 助手:env('APP_ENV')

                  and ofcourse, i am using env helper like this: env('APP_ENV')

                  但仍然没有成功.奇怪的是,$_ENV php 变量包含 .env 文件中的每个变量.

                  But still no success. The wierd part is, that $_ENV php variable contains every single variable from .env file.

                  推荐答案

                  env(...) 缓存配置后函数将无法工作.(从 laravel 5.2 到当前 5.7)

                  env(...) function will not work after you cached the config. (starting from laravel 5.2 till current 5.7)

                  Laravel 文档说

                  如果您在部署期间使用 config:cache 命令,则必须确保仅从配置文件中调用 env 函数,而不是从应用程序中的任何其他位置.

                  If you are using the config:cache command during deployment, you must make sure that you are only calling the env function from within your configuration files, and not from anywhere else in your application.

                  所以正确的答案是

                  如果您从应用程序中调用 env,强烈建议您将正确的配置值添加到配置文件中,然后从该位置调用 env,从而允许您将 env 调用转换为配置调用.

                  If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.

                  我从同一个文档

                  但为了快速修复,这样做可以:

                  But for a quick fix this will do:

                  php artisan config:clear

                  现在应该清楚为什么,当您尝试 config:cache 时,它没有帮助,即使它在缓存之前清除了配置.

                  And now it should be clear why, when you tried config:cache, it did not help, even though it clears the config prior to caching.

                  这篇关于Laravel 5 - env() 总是返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)
                • <small id='ZnYFz'></small><noframes id='ZnYFz'>

                    <bdo id='ZnYFz'></bdo><ul id='ZnYFz'></ul>

                    1. <tfoot id='ZnYFz'></tfoot>

                          <tbody id='ZnYFz'></tbody>
                        <i id='ZnYFz'><tr id='ZnYFz'><dt id='ZnYFz'><q id='ZnYFz'><span id='ZnYFz'><b id='ZnYFz'><form id='ZnYFz'><ins id='ZnYFz'></ins><ul id='ZnYFz'></ul><sub id='ZnYFz'></sub></form><legend id='ZnYFz'></legend><bdo id='ZnYFz'><pre id='ZnYFz'><center id='ZnYFz'></center></pre></bdo></b><th id='ZnYFz'></th></span></q></dt></tr></i><div id='ZnYFz'><tfoot id='ZnYFz'></tfoot><dl id='ZnYFz'><fieldset id='ZnYFz'></fieldset></dl></div>
                        <legend id='ZnYFz'><style id='ZnYFz'><dir id='ZnYFz'><q id='ZnYFz'></q></dir></style></legend>