I'm using Laravel 5.2 and I do php artisan config:cache
as recommended in the official documentation for speed improvement.
As you may know, this command makes the .env file variables directly inaccessibles (you can test it with php artisan tinker
), and for that reason all the calls to env()
and getenv()
function must be replaced by config()
in the code, except for the files in the config folder. After executing this command, calls like env('APP_ENV')
return NULL.
In my project, I'm connecting to Google Cloud using the google-auth-library-php. Unfortunately, in the CredentialsLoader.php file there is a call to the function getenv(self::ENV_VAR)
that attempts to get the path of the Google credentials file. As I run the command php artisan config:cache
, the path can't be read from the .env file and the connection cannot be completed.
I can see 3 ways to continue:
- Forget about running
php artisan config:cache
. - Ask here if somebody knows how to specify the path of the Google credentials file as a parameter of any function of the package.
- (Forgive me, God) Correct the CredentialsLoader.php file (
getenv()
toconfig()
), run the command and track this file in the repository, then this change will propagate to every team member when they pull.
Thank you in advance!