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


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





what version of laravel? Also, thats a PHP error in the artisan file, did you modify it?
– Derek
Jun 29 at 18:11





(Laravel 5.6 ) I did not modify the artisan file. But I have separated the core files from public ones and that might have broken something I am not aware of.
– Matthew Coatney
Jun 29 at 18:19





wait, does your laravel project have a .env ?
– Derek
Jun 29 at 18:26






yes. I changed the env file for mail and I can't get Laravel to see the new variable values.
– Matthew Coatney
Jun 29 at 18:27





Was it working prior to this? also, would you mind sharing the new env variables? substitute the values but make them structurally the same.
– Derek
Jun 29 at 18:30




1 Answer
1



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 cli


PHP 7.1.3



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:


artisan


$kernel = $app->make(IlluminateContractsConsoleKernel::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.



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






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV