Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Yii中的另一个命名空间中实例化对象?_Php_Yii2_Composer Php_Google Ads Api - Fatal编程技术网

Php 如何在Yii中的另一个命名空间中实例化对象?

Php 如何在Yii中的另一个命名空间中实例化对象?,php,yii2,composer-php,google-ads-api,Php,Yii2,Composer Php,Google Ads Api,我有以下几点 <?php namespace app\commands; use \Keyword as GoogleKeyword; class KwController extends \yii\console\Controller { public function actionTest() { $keyword = new GoogleKeyword(); } 我不明白,因为它过去是有用的 这就是它的定义 $ grep Keyword vendor/goo

我有以下几点

<?php
namespace app\commands;
use \Keyword as GoogleKeyword;

class KwController extends \yii\console\Controller
{

  public function actionTest() {
      $keyword = new GoogleKeyword();
  }
我不明白,因为它过去是有用的

这就是它的定义

$ grep Keyword vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/v201509/CampaignCriterionService.php
if (!class_exists("Keyword", false)) {
  class Keyword extends Criterion {
    const XSI_TYPE = "Keyword";
这里是
composer.json

{
    "require": {
        "googleads/googleads-php-lib": "~6.5"

下列任何一项都有效

use \Keyword as GoogleKeyword; // name clash
require 'vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/v201509/CampaignCriterionService.php'; # for Keyword


我认为
GetService
本身就有一些神奇的加载功能。

试着查看供应商内部/googleads/googleads php lib/src/Google/Api/Ads/AdWords/v201509/ActivityCriterionService.php并查看名称空间
use \Keyword as GoogleKeyword; // name clash
require 'vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/v201509/CampaignCriterionService.php'; # for Keyword
  public function actionTest() {
    $gaw = new GoogleAdWords();
    $user = $gaw->getUser(); # returns an AdWordsUser
    $campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
    $keyword = new GoogleKeyword();