Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 Yii2 和 composer 附加的“google/client”。问题是谷歌库的类名带有命名空间。例如。Client.php 具有类 Google_Client。Composer 的自动加载器不适用于该语法。我怎样才能让它工作?
放
use google\apiclient;
在命名空间中
然后使用:
set_include_path(Yii::$app->BasePath . '/vendor/google/apiclient/src');
还在类之前放置一个反斜杠以解析为命名空间,例如
$analytics = new \Google_Service_Analytics($client);