Laravel 5.2 {{env('APP_ENV')}}在生产中不起作用 [英] Laravel 5.2 {{ env('APP_ENV') }} does not work in production

查看:466
本文介绍了Laravel 5.2 {{env('APP_ENV')}}在生产中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码可用于我的开发环境(Ubuntu 14.04桌面)

The following code works on my development environment (Ubuntu 14.04 desktop)

@if(env('APP_ENV') === 'production')
    // ... something

但是由于某些原因,生产环境(ubuntu 14.04服务器)上的刀片视图无法获取env变量.

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.

有什么建议吗? 谢谢!

Any advice? Thanks!

推荐答案

所以,我成功了.

php artisan config:clear做到了.

  1. php artisan config:clear
  2. php artisan cache:clear
  3. service apache2 restart(以防万一)
  1. php artisan config:clear
  2. php artisan cache:clear
  3. service apache2 restart (just in case)

我猜是问题所在:

我第一次运行php artisan config:cache时,我的.env文件具有APP_ENV = local.因此,我必须清除该配置缓存,以获取新的环境变量值.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆