PHP Youtube 数据 API:未捕获的异常:必须通过 composer 或下载完整包安装此库

PHP Youtube Data API: Uncaught exception: This library must be installed via composer or by downloading the full package

我正在尝试使用 Google 客户端库访问 Youtube 数据 API,并使用来自 Google 的快速入门示例代码,供网络服务器使用 PHP。但是我在安装客户端库时遇到了问题,因为我使用了从 Github 中按文件下载整个文件夹的方法。

在 Google 客户端库的快速入门示例代码和安装指南中,他们要求 autoload.php 文件的路径包括一个名为 vendor 的文件夹,其中包含 autoload.php 文件。

If you downloaded the package separately, your require statement will look like this: require_once '/path/to/google-api-php-client/vendor/autoload.php';

Github 处的库文件中不存在此文件夹。

因此,我尝试根据需要制作文件结构,方法是将 autoload.php 文件从 google-api-php-client/src/google/ 复制到 google-api 中名为 vendor 的新文件夹-php-客户端。

执行quickstart.php文件时,出现这个错误:

Fatal error: Uncaught Exception: This library must be installed via composer or by downloading the full package. See the instructions at https://github.com/google/google-api-php-client#installation. in path\to\project\google-api-php-client\vendor\autoload.php:14 Stack trace: #0 path\to\project\quickstart.php(11): require_once() #1 {main} thrown in path\to\project\google-api-php-client\vendor\autoload.php on line 14

这是我使用的文件结构:
项目文件夹
google-api-php-客户端文件夹
源文件夹
供应商文件夹
autoload.php 文件
client_secrets.json 文件
quickstart.php 文件

这里有一个重复的线程:Missing vendor/autoload.php in google-api-php-client-master 但它没有解决,所以我正在寻找可以帮助解决这个问题的答案。

我解决了。 Api 客户端库必须从这里下载 https://github.com/google/google-api-php-client/releases and not https://github.com/google/google-api-php-client.

页面上的文件夹本身似乎已经足够好了,但您可以从发行版中获得更好的文件夹,但事实并非如此,因为它只是发行版上的版本,如果您不要使用 composer 方法。