laravel-google-ads icon indicating copy to clipboard operation
laravel-google-ads copied to clipboard

php artisan config:cache

Open martijnimhoff opened this issue 5 years ago • 3 comments

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.

martijnimhoff avatar Oct 23 '19 09:10 martijnimhoff

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')),
    // ...
    ],
];

Techworker avatar Jan 23 '20 12:01 Techworker

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.

martijnimhoff avatar Jan 23 '20 13:01 martijnimhoff

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.

mwargan avatar Oct 07 '20 20:10 mwargan