php Dynamic Namespaces to handle new versions of API

15 views
Skip to first unread message

Mike Enos

unread,
Jan 14, 2019, 12:32:31 PM1/14/19
to AdWords API and Google Ads API Forum
I have hundreds of php scripts much like /examples/Adwords/v201809/BasicOperations/GetCampaignsWithAwql.php

Each time there is an API version update I need to go and manually EVERY file to use the new version, and make sure NONE are missed.

Yuck!!!!!

For example:
namespace Google\AdsApi\Examples\AdWords\v201809\BasicOperations;

require __DIR__ . '/../../../../vendor/autoload.php';

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\Query\v201809\ServiceQueryBuilder;
use Google\AdsApi\AdWords\v201809\cm\CampaignService;
use Google\AdsApi\AdWords\v201809\cm\Page;
use Google\AdsApi\Common\OAuth2TokenBuilder;


What would be awesome is if I could have a file like "latestAPIVersion.php" which contained simply  "$version = "v201809"
and I could include that file.


It doesn't seem the use or namespace command allows variables ie.. namespace Google\AdsApi\Examples\AdWords\$version\BasicOperations;

What is everyone else doing out there to handle this?

Thanks





Milind Sankeshware (AdWords API Team)

unread,
Jan 14, 2019, 3:20:47 PM1/14/19
to AdWords API and Google Ads API Forum
Hi Mike,

Unfortunately, you may need to do that for pointing to the latest version at your end. I will let other users share their inputs if they are handling it differently.

Thanks,
Milind, AdWords API Team
Reply all
Reply to author
Forward
0 new messages