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

前提是你 提交于 2019-12-23 17:26:32

问题


Tried to run the trans.php program from wamp server from the path

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

I have included the AWS folder in

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

And AWS credential file in wamp/www folder as well user directory for the access

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

This is my program

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

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

   // no error here.
  ?>

When i'm trying to run the program, I get this error

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

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

What change should I make ?


回答1:


Use composer.

Create testaws directory and put composer.json file with content below (you can adjust it to your needs for example PHP version or dev packages)

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

run composer install

then in index.php in testaws directory put this line in index.php

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

After you do this steps it should work. More about composer you will find there

Also you can find sample project here




回答2:


There are two main problems are:

1 Composer Autoloading

The AWS dependency needs to be downloaded with Composer, if you want the Composer Autoloader to work correctly. Do not move folders around, when working with Composer. The autoloading expects the files and folders inside the vendor folder.

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

You don't need to do this manually.

2 The use statement is wrong.

Change use Amazon\Aws\ElasticTranscoder\ElasticTranscoderClient;

to use \Aws\ElasticTranscoder\ElasticTranscoderClient;

3 Example Application

Because it is your third question and you seem to have problems with the application structure in connection with Composer, i will provide a simple PHP application template to demonstrate how you work with the AWS dependency.

This example provides a basic namespaced PHP application and includes the Client class from the AWS dependency(, which you have to fetched by Composer).

You find the file over here: https://www.dropbox.com/s/q1b406thgu3146n/php-app-composer-aws.zip?dl=0

Extract the test folder into your www folder. Then execute a composer install and run index.php. You will end up with a error from TranscoderClient, because it expects a configuration. Not part of the problem.




回答3:


Delete the vendors folder and run composer install.



来源:https://stackoverflow.com/questions/32775389/fatal-error-require-failed-opening-required-c-wamp-www-sep24-e-src-functio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!