Thursday, 7 September 2017

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



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...


Answer




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.


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...