3

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 ?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Reaching-Out
  • 415
  • 6
  • 26

3 Answers3

1

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.

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • Yes I'm getting the structure and the flow now. Now I'm getting a different error.. "Fatal error: Uncaught exception 'Aws\ElasticTranscoder\Exception\ElasticTranscoderException' with message 'Error executing "CreateJob" on "https://elastictranscoder.ap-southeast-1.amazonaws.com/2012-09-25/jobs"; AWS HTTP error: Client error: 404 ResourceNotFoundException (client): The specified pipeline was not found: account=xxxxx, pipelineId=xxxxxxx. - {"message":"The specified pipeline was not found: account=xxxxx, pipelineId=xxxxxxx."}'" – Reaching-Out Sep 26 '15 at 05:47
  • 1
    I think its an configuration issue of pipeline and region. Check your AWS console and make sure pipeline region and create job region are the same. See http://stackoverflow.com/a/20851922/1163786 – Jens A. Koch Sep 26 '15 at 08:51
  • Can u please take a look at this -> [link](http://stackoverflow.com/questions/32866062/copy-files-within-s3-bucket) – Reaching-Out Sep 30 '15 at 12:27
  • The question was deleted. Can not help. - (Off-topic and shameless plug: i see you are using WAMP, maybe you could give http://wpn-xm.org a try.) – Jens A. Koch Sep 30 '15 at 12:50
  • Yeah. Its been deleted. Don't know how. Thank You though. – Reaching-Out Oct 01 '15 at 09:23
  • Can you please take a look at this [here](http://stackoverflow.com/questions/32945202/s3-bucket-content-is-not-getting-listed-till-last) @ Jens A. Koch – Reaching-Out Oct 05 '15 at 09:37
0

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

Robert
  • 19,800
  • 5
  • 55
  • 85
  • While running the first step I'm getting this error " [InvalidArgumentException] Could not find package testaws with stability stable. " – Reaching-Out Sep 25 '15 at 12:33
  • My mistake create project command create project from existing repository. So instead of this you should create sample composer.json file I will edit my answer – Robert Sep 25 '15 at 13:34
  • you have not given anything for autoload in composer.json For Ex: "autoload": { "psr-4": { "Aws\\": "src/" }, "files": ["src/functions.php"] }. Will that work? – Reaching-Out Sep 26 '15 at 03:40
  • The PSR-4 part of this autoload section will work, but clashes with the aws dependency. Because in your composer.json you define the autoloading of your project **not** of dependencies. Normally, you have to define your application namespace here, which points to your src folder. What you are doing now is to reuse the existing namespace of the aws sdk and point that to your src folder. Thereby you include all your files and class into the AWS namespace, which might lead to class name clashes. The autoload "files" definition works, if the file exists. – Jens A. Koch Sep 26 '15 at 08:50
0

Delete the vendors folder and run composer install.

Marooweb
  • 476
  • 3
  • 8
  • 21