Laravel 5.2 {{ env('APP_ENV') }} 在生产环境中不起作用 [英] Laravel 5.2 {{ env('APP_ENV') }} does not work in production
问题描述
以下代码适用于我的开发环境(Ubuntu 14.04 桌面)
The following code works on my development environment (Ubuntu 14.04 desktop)
@if(env('APP_ENV') === 'production')
// ... something
但由于某种原因,生产环境(ubuntu 14.04 服务器)上的刀片视图没有获取环境变量.
But for some reason, the blade views on production (ubuntu 14.04 server) aren't getting the env variables.
如果我运行 php artisan env
响应就好了:当前应用程序环境:生产
If I run php artisan env
the response is just fine: Current application environment: production
数据库连接正常.从控制器调用的 env() 助手也可以工作.
The database connection works fine. And the env() helper called from the controllers, also works.
到目前为止我尝试过的:
What I tried so far:
php artisan clear:cache
php artisan config:cache
php artisan clear:cache
php artisan view:clear
我也多次重启apache,没有结果.
I also restarted apache multiple times, no results.
有什么建议吗?谢谢!
推荐答案
所以,我成功了.
php artisan config:clear
成功了.
php artisan config:clear
php artisan cache:clear
service apache2 restart
(以防万一)
php artisan config:clear
php artisan cache:clear
service apache2 restart
(just in case)
我猜的问题是:
我第一次运行 php artisan config:cache
我的 .env 文件有 APP_ENV=local.因此,我必须清除该配置缓存才能获得新的 env vars 值.
The first time I run php artisan config:cache
my .env file had APP_ENV=local. So I had to clear that config cache in order to get the new env vars values.
这篇关于Laravel 5.2 {{ env('APP_ENV') }} 在生产环境中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!