0

我使用 Yii2 和 composer 附加的“google/client”。问题是谷歌库的类名带有命名空间。例如。Client.php 具有类 Google_Client。Composer 的自动加载器不适用于该语法。我怎样才能让它工作?

4

1 回答 1

1

use google\apiclient; 

在命名空间中

然后使用:

set_include_path(Yii::$app->BasePath  . '/vendor/google/apiclient/src');

还在类之前放置一个反斜杠以解析为命名空间,例如

$analytics = new \Google_Service_Analytics($client);

于 2014-12-19T21:49:34.877 回答