有没有其他方法可以让 Laravel 重新加载环境变量?

Is there any other way to get Laravel to reload env variables?

我在知名主机上有一个共享主机帐户。

我的 Laravel 网站已上传并大部分正常运行。但是我必须进行环境更改。现在我无法 Laravel 看到更改。

我知道这是一个常见问题。我已经尝试 运行 artisan 命令来清除配置和缓存 (php artisan config:cache & php artisan cache:clear ) 但这失败并出现错误:

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 刷新其缓存?

提前TY...

问题

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

更具体地说,您收到此错误的确切原因来自 documentation:

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 file 中的第 33 行:

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

并且由于当您通过 CLI 运行 命令时服务器是 运行ning 5.4,PHP 不知道语法的含义,因此它会抛出错误。

修复

为了解决这个问题,您需要升级 PHP 版本。