Fatal error: require(): Failed opening required 'C:\wamp\www\sep24\e/src/functions.php' (include_path='.;C:\php\pear')

Fatal error: require(): Failed opening required 'C:\wamp\www\sep24\e/src/functions.php' (include_path='.;C:\php\pear')

试图从路径

运行 来自 wamp 服务器的 trans.php 程序

C:\wamp\www\sep24\e\trans.php

我已将 AWS 文件夹包含在

C:\wamp\www\sep24\e\Amazon\

以及 wamp/www 文件夹中的 AWS 凭证文件以及用于访问的用户目录

C:\wamp\www\.aws\credentials & C:\Users\username\.aws\credentials

这是我的程序

<?php
 define('ROOT', dirname(__FILE__));
 require ROOT . '/vendor/autoload.php';
 use Amazon\Aws\ElasticTranscoder\ElasticTranscoderClient;

  -------------
  ------------

   // no error here.
  ?>

当我尝试 运行 程序时,出现此错误

Fatal error: require(): Failed opening required 'C:\wamp\www\sep24\e/src/functions.php' (include_path='.;C:\php\pear') in C:\wamp\www\sep24\e\vendor\composer\autoload_real.php on line 54

我已经包含了我从 git 下载的所有 AWS 软件包。

我应该做出什么改变?

主要有两个问题:

1 个 Composer 自动加载

AWS依赖需要用Composer下载, 如果您希望 Composer Autoloader 正常工作。 使用 Composer 时,不要四处移动文件夹。 自动加载需要供应商文件夹中的文件和文件夹。

I have included all the packages of AWS which I downloaded from the git.

您不需要手动执行此操作。

2 use 说法错误。

改变use Amazon\Aws\ElasticTranscoder\ElasticTranscoderClient;

use \Aws\ElasticTranscoder\ElasticTranscoderClient;

3 个示例应用程序

因为这是你的第三个问题,而且你似乎对与 Composer 相关的应用程序结构有疑问,我将提供一个简单的 PHP 应用程序模板来演示你如何使用 AWS 依赖项。

此示例提供了一个基本的命名空间 PHP 应用程序,并包括来自 AWS 依赖项的客户端 class(您必须通过 Composer 获取它)。

您可以在此处找到该文件: https://www.dropbox.com/s/q1b406thgu3146n/php-app-composer-aws.zip?dl=0

将测试文件夹解压到您的 www 文件夹中。 然后执行一个composer install和运行index.php。 您最终会收到来自 TranscoderClient 的错误,因为它需要一个配置。不是问题的一部分。

使用作曲家。

创建 testaws 目录并放入 composer.json 文件,内容如下(您可以根据需要调整它,例如 PHP 版本或开发包)

{
    "name": "yourname/sampleapp",
    "description": "Sample app",
    "require": {
        "php": ">=5.5.0",
        "aws/aws-sdk-php" :  "dev-master"
    },
}

运行 composer install

然后在 testaws 目录中的 index.php 中将此行放入 index.php

require __DIR__ . '/vendor/autoload.php';

执行此步骤后,它应该会起作用。关于作曲家的更多信息,您会发现 there

您还可以找到示例项目here

删除 vendors 文件夹并运行 composer install。