SnowYou
SnowYou

Reputation: 39

Can't create 'new Class' even after including it

I'm using the googleAds API, but when I include a class that I need in my function it still shows me an error :

Error: Class 'TargetingIdeaSelector' not found
File: C:\wamp64\www\projet\app\Model\Keyword.php
Line: 26

I'm including it like this :

include 'C:\wamp64\www\projet\vendors\googleads\googleads_php_lib\src\Google\AdsApi\AdWords\v201710\o\TargetingIdeaSelector.php';

And further in my function, I'm using this :

// Create selector.
$selector = new TargetingIdeaSelector();

Bringing me the error above. Is there something else to do to use a class previously included ?

Upvotes: 0

Views: 93

Answers (1)

SnowYou
SnowYou

Reputation: 39

Got a fix from someone better than me :

 require_once __DIR__ . '../../Vendor/autoload.php';

use Google\AdsApi\AdWords\v201710\o\TargetingIdeaSelector;
use Google\AdsApi\AdWords\v201710\o\LanguageSearchParameter;
use Google\AdsApi\AdWords\v201710\o\RelatedToQuerySearchParameter;
use Google\AdsApi\AdWords\v201710\cm\Language;
use Google\AdsApi\AdWords\v201710\cm\Paging;

It was all about using the good namespaces, I just was overloaded by the quantity of files in my project and couldn't figure out the solution out of my mess. My bad :)

Upvotes: 1

Related Questions