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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 01:26:51

问题


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

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.

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:

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

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

TY in advance...


回答1:


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.

More specifically, the exact reason you're getting this error, from the 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.

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

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

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.

THE FIX

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



来源:https://stackoverflow.com/questions/51107273/is-there-any-other-way-to-get-laravel-to-reload-env-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!