Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php artisan config:cache #47

Open
martijnimhoff opened this issue Oct 23, 2019 · 3 comments
Open

php artisan config:cache #47

martijnimhoff opened this issue Oct 23, 2019 · 3 comments

Comments

@martijnimhoff
Copy link

I've setup my google-ads.php config file with env() helpers, because I want to follow the good practice of not putting credentials in my repo history.

However when I run php artisan config:cache, the google ads package isn't working anymore. I guess that the package is still looking in the google-ads.php file, which now returns null on each value, because when you run php artisan config:cache. The env() will always return null.

@Techworker
Copy link

Yes, it seems to work with an include on the config file instead of the laravel config() function. See here:

https://github.com/Edujugon/laravel-google-ads/blob/master/src/Support/helpers.php#L52-L67

There is a workaround, you might give this a try in your google-ads.php config file:

return [
    'env' => 'test',
    'test' => [
        'developerToken' => env('GOOGLE_ADS_DEVELOPER_TOKEN', config('google-ads.test.developerToken')),
        'clientCustomerId' => env('GOOGLE_ADS_CUSTOMER_ID', config('google-ads.test.clientCustomerId')),
    // ...
    ],
];

@martijnimhoff
Copy link
Author

Looks nasty, but it might work.

I've tried to recreate the error of this issue, but it seems to be working fine atm. Even without the workaround, it's still able to get the filled contents of google-ads.php.

It seems the behavior of env() has changed. Still it would be better to use config() because of the performance boost from php artisan config:cache.

@mwargan
Copy link

mwargan commented Oct 7, 2020

Yes, it seems to work with an include on the config file instead of the laravel config() function. See here:

https://github.com/Edujugon/laravel-google-ads/blob/master/src/Support/helpers.php#L52-L67

There is a workaround, you might give this a try in your google-ads.php config file:

return [
    'env' => 'test',
    'test' => [
        'developerToken' => env('GOOGLE_ADS_DEVELOPER_TOKEN', config('google-ads.test.developerToken')),
        'clientCustomerId' => env('GOOGLE_ADS_CUSTOMER_ID', config('google-ads.test.clientCustomerId')),
    // ...
    ],
];

This didn't work for me since the test variables are also in the .env file, and thus using env(). I can +1 that the issue only occurs when the config is cached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants