我在哪里放置autoloader.php的require代码?

时间:2016-12-30 15:22:40

标签: drupal-7 google-api-php-client drupal-feeds

我显然是新手。但我在安装google-api-php-client库时遇到问题。在Google的文档页面上,它说:

获取文件后,请包含自动加载器。如果您使用Composer,则您的require语句将如下所示:

require_once '/path/to/your-project/vendor/autoload.php';

如果您单独下载了该软件包,则您的require语句将如下所示:

require_once '/path/to/google-api-php-client/vendor/autoload.php';

我知道这可能是一个简单的答案,但在我的项目中,我应该放置代码吗?

google-api-php-client目录中是否有一个文件我应该放入这行?或者我是否需要将此行直接放入我的网站的HTML中才能正确安装库?

我正在使用Drupal 7并且我使用composer安装了该库。

1 个答案:

答案 0 :(得分:0)

假设我有3个文件, mail.php calendar.php drive.php 。使用 mail.php ,我运行一个脚本,通过我的谷歌帐户发送电子邮件, calendar.php 我运行一个脚本,在我的日历中插入一个新事件,并带有< strong> drive.php 我运行一个脚本,将文件上传到我的驱动器。 这些文件中的每一个都需要require_once '/path/to/your-project/vendor/autoload.php';之后的<?php。例如:

<?php session_start();

require_once '/path/to/your-project/vendor/autoload.php';

//run the rest of your script that requires interacting with google services.

请查看位于here的文档中的示例以及示例here