在 Laravel 5.2 中重新加载 .env 常量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37849436/
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
Reload .env constants in Laravel 5.2
提问by John Smith
I just changed a constant inside my .env file. The new value is shown up correctly with php-cli (via tinker), but not in my web app (php-fpm).
我只是在我的 .env 文件中更改了一个常量。新值使用 php-cli(通过 tinker)正确显示,但不在我的网络应用程序 (php-fpm) 中显示。
So far I've tried everything as suggested:
到目前为止,我已经按照建议尝试了所有方法:
sudo service nginx restart
sudo service php7.0-fpm restart
sudo service php7.0-fpm reload
.
.
php artisan config:cache
This will generate a cache config file in bootstrap/cache/config.php
这将在 bootstrap/cache/config.php 中生成一个缓存配置文件
php artisan config:clear
This will remove cache config file in bootstrap/cache/config.php
这将删除 bootstrap/cache/config.php 中的缓存配置文件
php artisan cache:clear
What exactly does does ? What type of cache does it clear?
究竟是做什么的?它清除什么类型的缓存?
php artisan clear-compiled
This clear compile classes
这个明确的编译类
composer dump-autoload
This will generate/update composer autoload file.
这将生成/更新作曲家自动加载文件。
I have some .env variables that are not part of any config file. So it is useless for me to run any of the artisan commands.
我有一些不属于任何配置文件的 .env 变量。所以我运行任何工匠命令都没有用。
None of the above php artisan commands don't deal directly with $_ENV.
以上 php artisan 命令都没有直接处理 $_ENV。
Seems that $_ENV is stored somewhere in the server and laravel cannot update it once properties are populated.
似乎 $_ENV 存储在服务器的某个地方,一旦属性被填充,laravel 就无法更新它。
The only solution I've found is restarting the server.
我找到的唯一解决方案是重新启动服务器。
I'm running a Laravel Forge instance.
我正在运行 Laravel Forge 实例。
回答by James
If it is cached and you need to reload it you can simply use:
如果它被缓存并且您需要重新加载它,您可以简单地使用:
php artisan config:clear
php artisan config:clear
This will pull in any changes that you have since made.
这将引入您此后所做的任何更改。
回答by Mauro Baptista
Try to delete the config on file on: Bootstrap/cache/config.php
尝试删除文件上的配置:Bootstrap/cache/config.php
AS well you can try: php artisan config:cache or php artisan cache:clear
你也可以尝试: php artisan config:cache 或 php artisan cache:clear