我试图use this Google Analytics API tutori al,但它依赖于Guzzle。我收到了这个错误:
Fatal error: Class 'GuzzleHttp\Collection' not found in ../google-api-php-client/src/Google/Client.php on line 93
但我已经安装了Guzzle:
>>php composer.phar require guzzlehttp/guzzle:~5.2
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing react/promise (v2.2.1)
Downloading: 100%
- Installing guzzlehttp/streams (3.0.0)
Downloading: 100%
- Installing guzzlehttp/ringphp (1.1.0)
Downloading: 100%
- Installing guzzlehttp/guzzle (5.3.0)
Downloading: 100%
Writing lock file
Generating autoload files
这是我的composer.json:
"require": {
"php": ">=5.4",
"google/auth": "v0.3",
"monolog/monolog": "^1.17",
"phpseclib/phpseclib": "~2.0",
"guzzlehttp/guzzle": "5.3.*"
},
答案 0 :(得分:2)
您必须包含Composer的自动加载文件,如下所述:https://getcomposer.org/doc/01-basic-usage.md#autoloading
在主文件中,在顶部添加以下行(在需要这些文件的任何代码之前):
require __DIR__ . '/vendor/autoload.php';