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();