还有其他方法可以让Laravel重新加载环境变量吗? [英] Is there any other way to get Laravel to reload env variables?

查看:111
本文介绍了还有其他方法可以让Laravel重新加载环境变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在知名主机上有一个共享的托管帐户.

I have a shared hosting account on a well known host.

我上传了我的Laravel网站,并且大部分时间都在运行.但是我不得不做一个环境改变.现在我无法让Laravel看到更改.

I have my Laravel site uploaded and functioning for the most part. But I had to make an env change. Now I can't get Laravel to see the change.

我知道这是常见问题.我尝试运行artisan命令以清除配置和缓存(php artisan config:cache& php artisan cache:clear),但这失败并显示错误:

I know this is common issue. I have tried running the artisan commands to clear config and cache (php artisan config:cache & php artisan cache:clear ) but this fails with an error:

解析错误:语法错误,意外的类"(T_CLASS),期望的标识符(T_STRING)或变量(T_VARIABLE)或第33行的/home4/cmatthewc/cvbaptistapp/artisan中的"{"或"$" >

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home4/cmatthewc/cvbaptistapp/artisan on line 33

还有其他方法可以使Laravel从env刷新其缓存吗?

Is there any other way to get Laravel to refresh its cache from env?

提前TY ...

推荐答案

问题

问题出在服务器的php cli版本中. Laravel 5.6希望您的PHP 7.1.3或更高.

THE ISSUE

The issue lies in the php cli version of the server. Laravel 5.6 expects you to have PHP 7.1.3 or greater.

更具体地说,您从

从PHP 5.5开始,class关键字也用于类名 解析度.您可以获得包含完全限定名称的字符串 通过使用ClassName :: class获得ClassName类.特别是 对于命名空间的类很有用.

Since PHP 5.5, the class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with namespaced classes.

如果您在 artisan文件中的第33行 a>在您的项目根目录中:

And if you look on line 33 in the artisan file in your project root:

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

由于当您通过CLI运行命令时服务器正在运行5.4,因此PHP不了解语法的含义,因此会引发错误.

And since the server is running 5.4 when you run commands via the CLI, PHP has no idea what the syntax means, so it throws an error.

要解决此问题,您需要升级PHP版本.

In order to fix this, you'll need to upgrade your PHP version.

这篇关于还有其他方法可以让Laravel重新加载环境变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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