Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Fatal error: require(): Failed opening required '/var/www/html/vendor/autoload.php' #3

Open
selvakumarEsra opened this issue May 2, 2016 · 7 comments

Comments

@selvakumarEsra
Copy link

When i run the ${PUBLIC_IP}/dynamodb/createtables.php , we get following error,
please fix the code so that other beginer will not face the issue.

Thanks,
Selva

Warning: require(/var/www/html/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/dynamodb/createtables.php on line 12

Fatal error: require(): Failed opening required '/var/www/html/vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/dynamodb/createtables.php on line 12

@furkankadioglu
Copy link

Needs to composer & require aws-sdk-php.

@nandakishore8031
Copy link

I got the same error too. Please let me know what to be done.

@unacceptable
Copy link

unacceptable commented Mar 14, 2017

Hello all,

I have just run into this issue as well. I was able to resolve this by finding where the file was located and modifying the php script to match. (I literally only added 'dynamodb/' to the file path as specified in the script):

[root@ip-172-31-12-207 dynamodb]# ll /var/www/html/vendor/autoload.php
ls: cannot access /var/www/html/vendor/autoload.php: No such file or directory
[root@ip-172-31-12-207 dynamodb]# ll ..
total 8
drwxr-xr-x 4 root root 4096 Mar 14 06:03 dynamodb
-rw-r--r-- 1 root root   19 Mar 14 05:39 test.php
[root@ip-172-31-12-207 dynamodb]# find . -name autoload.php
./vendor/autoload.php
[root@ip-172-31-12-207 dynamodb]# cp -a createtables.php{,$(date +%F)}
[root@ip-172-31-12-207 dynamodb]# cp -a uploaddata.php{,$(date +%F)}
[root@ip-172-31-12-207 dynamodb]# vim createtables.php
[root@ip-172-31-12-207 dynamodb]# vim uploaddata.php
[root@ip-172-31-12-207 dynamodb]# diff createtables.php*
12c12
<     require '/var/www/html/dynamodb/vendor/autoload.php';
---
>     require '/var/www/html/vendor/autoload.php';
[root@ip-172-31-12-207 dynamodb]# diff uploaddata.php*
11c11
<     require '/var/www/html/dynamodb/vendor/autoload.php';
---
>     require '/var/www/html/vendor/autoload.php';
[root@ip-172-31-12-207 dynamodb]#

Line numbers for the lines in these files are as follows (note that the period is a hard link to the current working directory). There will also be an error for describing the line number of the failure in the web browser.

[root@ip-172-31-12-207 dynamodb]# grep -nr /var/www/html/dynamodb/vendor/autoload.php .
./uploaddata.php:11:    require '/var/www/html/dynamodb/vendor/autoload.php';
./createtables.php:12:    require '/var/www/html/dynamodb/vendor/autoload.php';
[root@ip-172-31-12-207 dynamodb]#

Hopefully this will clear up this for some people. ACloudGuru please update this at your earliest convenience.

Respectfully,
Robert J.

@GodStorm91
Copy link

As in my casse I do the following
[ec2-user@ip-172-31-26-96 www]$ sudo su
[root@ip-172-31-26-96 www]$ cd /var/www/html
[root@ip-172-31-26-96 www]$ cd /var/www/html
Install the required sdk
[root@ip-172-31-26-96 html]# php composer.phar require aws/aws-sdk-php

And the result when I rerun
image

@aniket91
Copy link

aniket91 commented Apr 15, 2018

You need composer and AWS SDK for PHP. This is already in the updated video of ACloudGuru. Details are in - https://docs.aws.amazon.com/aws-sdk-php/v2/guide/installation.html

Go to /var/www/html directory and run following commands -


[root@ip-172-31-28-207 html]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.6.4) successfully installed to: /var/www/html/composer.phar
Use it: php composer.phar

[root@ip-172-31-28-207 html]# php composer.phar require aws/aws-sdk-php
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^3.54 for aws/aws-sdk-php
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
  - Installing mtdowling/jmespath.php (2.4.0): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.3.2): Downloading (100%)         
  - Installing aws/aws-sdk-php (3.54.4): Downloading (100%)         
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
aws/aws-sdk-php suggests installing aws/aws-php-sns-message-validator (To validate incoming SNS notifications)
aws/aws-sdk-php suggests installing doctrine/cache (To use the DoctrineCacheAdapter)
Writing lock file
Generating autoload files

Then you should have all required files in html directory -

[root@ip-172-31-28-207 html]# ll
total 1840
-rw-r--r-- 1 root root      62 Apr 15 07:13 composer.json
-rw-r--r-- 1 root root   12979 Apr 15 07:13 composer.lock
-rwxr-xr-x 1 root root 1848805 Apr 15 07:12 composer.phar
drwxr-xr-x 3 root root    4096 Apr 15 07:09 dynamodb
-rw-r--r-- 1 root root      19 Apr 15 07:00 test.php
drwxr-xr-x 8 root root    4096 Apr 15 07:13 vendor

@temmyakins
Copy link

This error could even actually be that your composer.phar needs to be updated.

If you observe carefully you will notice that when you run ls on your html you might not find composer.lock
Also regarding this issue, if you navigate to your vendor folder i.e. cd Vendor, you will notice it doesn't have the "autoload.php" which is the main cause of the issue.

Sometimes even after running the curl -sS https://getcomposer.org/installer | php
and php composer.phar require aws/aws-sdk-php. You can get some error in between saying

[root@ip-172-31-18-42 html]# php composer.phar require aws/aws-sdk-php Using version ^2.8 for aws/aws-sdk-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals

PHP Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/w ww/html/composer.phar/vendor/symfony/console/Application.php on line 959

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/ht ml/composer.phar/vendor/symfony/console/Application.php on line 959

[ErrorException]
proc_open(): fork failed - Cannot allocate memory

In a nut shell, Just simple run the command below in the hmtl directory

php composer.phar update

Then you are good to go, Your files will update in the dynamodb sucessfully after wards.

Cheers.

@ManalLiaquat
Copy link

You need composer and AWS SDK for PHP. This is already in the updated video of ACloudGuru. Details are in - https://docs.aws.amazon.com/aws-sdk-php/v2/guide/installation.html

Go to /var/www/html directory and run following commands -


[root@ip-172-31-28-207 html]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.6.4) successfully installed to: /var/www/html/composer.phar
Use it: php composer.phar

[root@ip-172-31-28-207 html]# php composer.phar require aws/aws-sdk-php
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^3.54 for aws/aws-sdk-php
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
  - Installing mtdowling/jmespath.php (2.4.0): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.3.2): Downloading (100%)         
  - Installing aws/aws-sdk-php (3.54.4): Downloading (100%)         
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
aws/aws-sdk-php suggests installing aws/aws-php-sns-message-validator (To validate incoming SNS notifications)
aws/aws-sdk-php suggests installing doctrine/cache (To use the DoctrineCacheAdapter)
Writing lock file
Generating autoload files

Then you should have all required files in html directory -

[root@ip-172-31-28-207 html]# ll
total 1840
-rw-r--r-- 1 root root      62 Apr 15 07:13 composer.json
-rw-r--r-- 1 root root   12979 Apr 15 07:13 composer.lock
-rwxr-xr-x 1 root root 1848805 Apr 15 07:12 composer.phar
drwxr-xr-x 3 root root    4096 Apr 15 07:09 dynamodb
-rw-r--r-- 1 root root      19 Apr 15 07:00 test.php
drwxr-xr-x 8 root root    4096 Apr 15 07:13 vendor

This solves my problem
Thanks @aniket91

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants