Laravel 5.2 {{env('APP

编程入门 行业动态 更新时间:2024-10-28 18:25:23
本文介绍了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做到了.

  • 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.因此,我必须清除该配置缓存,以获取新的环境变量值.

    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

    本文发布于:2023-05-31 10:02:06,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/389498.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Laravel   env   APP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!