【问题标题】:Where do I put the require code for autoloader.php?我在哪里放置 autoloader.php 的要求代码?
【发布时间】:2016-12-30 15:22:40
【问题描述】:

我显然是新手。但我在安装 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 安装了库。

【问题讨论】:

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


    【解决方案1】:

    假设我有 3 个文件,ma​​il.phpcalendar.phpdrive.php。使用 ma​​il.php,我运行一个从我的 google 帐户发送电子邮件的脚本,使用 calendar.php 我运行一个在我的日历中插入新事件的脚本,使用 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

    【讨论】:

      猜你喜欢
      • 2019-09-18
      • 2015-10-31
      • 1970-01-01
      • 2015-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      相关资源
      最近更新 更多