谷歌API我的企业+;PHP+;未找到Laravel-类

谷歌API我的企业+;PHP+;未找到Laravel-类,php,laravel-5,google-api-php-client,google-api-client,google-my-business-api,Php,Laravel 5,Google Api Php Client,Google Api Client,Google My Business Api,我使用OAuth 2.0 flow+google api php client+Mybusiness php类,但出现错误“未找到类”,请参见以下内容: use App\Vendors\Google_Service_MyBusiness as MyBusiness; .... $gClient->setAccessToken($access_token); $oauth2 = new \Google_Service_Oauth2($gClient); $userInfo = $oauth

我使用OAuth 2.0 flow+google api php client+Mybusiness php类,但出现错误“未找到类”,请参见以下内容:

use App\Vendors\Google_Service_MyBusiness as MyBusiness;
....

$gClient->setAccessToken($access_token);
$oauth2 = new \Google_Service_Oauth2($gClient);
$userInfo = $oauth2->userinfo->get();
print_r($userInfo); //Works!

$mybusinessService = new MyBusiness($gClient);

//return Class 'Google_Service_MyBusiness_Location' not found:
$mybusinessService->accounts->get('accounts/xxxxxxxx');

//return 'Google_Service_MyBusiness_ListAccountsResponse' not found:
$accounts = $mybusinessService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
完全错误:

Class 'Google_Service_MyBusiness_Account' not found in file /vendor/google/apiclient/src/Google/Http/REST.php on line 128
自动加载中添加的MyBusiness类:

"autoload" : {
    "files": [
        "app/Vendors/MyBusiness.php"
    ]
}
所有必需的CLS(例如,
Google\u Service\u MyBusiness\u list accounts response
Google\u Service\u MyBusiness\u Location
位于
app/Vendors/MyBusiness.php


我的代码有什么问题?

在函数listAccounts()第1262行更改

发件人:

致:


供应商目录不在
App/vendor

像这样试试

$service = new \Google_Service_MyBusiness($client);

您是否使用composer来设置此设置?其他自动加载工作吗?我不确定这段代码到底在哪里,它是否在某个类中被其他调用?如果它在一个单独的文件中,我希望看到一些引导代码包含自动加载文件,就像在laravel索引中一样file@mickadoo我使用作曲家。代码在控制器中。其他自动加载工作。文件
app/Vendors/MyBusiness.php
有许多类:Class
Google\u Service\u MyBusiness
在controller和works中可见,但此文件中的其他类在
vendor/Google/apiclient/src/Google/Http/REST.php中使用不可见。这是您的完整答案吗?您是否尝试手动要求包含该类的文件?如果这是可行的,那么它应该缩小到一个自动加载的问题。如果您修改了一些自动加载的内容,您可以尝试安装一个
composer
,它应该会重新生成自动加载files@mickadoo你能给我一个示例代码吗?我对拉威尔不是很有经验。邮件问题是,
app/Vendors/MyBusiness.php
中声明的一个类必须用于
vendor/google/apiclient/src/google/Http/REST.php
(见第128行),并且不可见。我不确定问题是什么,但它可能是自动加载的。如果您在
app/Vendors/MyBusiness.php
中有
Google\u Service\u MyBusiness\u Account
类,您可以通过手动将这一行添加到index.php中,或者在调用问题代码之前的任何地方,确保一切正常运行:
require\u once\u DIR\uuuuuuuuuuuu/path/to/MyBusiness.php'(将/path/to替换为实际路径。如果可行,则可以继续调试自动加载不起作用的原因
return $this->call('list', array($params), "App\Services\Integrations\GoogleApi\Google_Service_MyBusiness_ListAccountsResponse");
$service = new \Google_Service_MyBusiness($client);