Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why aws.phar runs once then won't load again?

I install aws sdk for php in my elastic beanstalk application using phar file,:

require_once __DIR__ . '/../AWS-SDK/aws.phar';

when I run the script for the first time, it succeed ! but when I try again I got this error :

Warning: require(phar://aws.phar/aws-autoloader.php): failed to open stream: phar error: invalid url or non-existent phar "phar://aws.phar/aws-autoloader.php" in /var/app/current/src/utils/AWS-SDK/aws.phar on line 3 Fatal error: require(): Failed opening required 'phar://aws.phar/aws-autoloader.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/app/current/src/utils/AWS-SDK/aws.phar on line 3

How to solve the problem ?

like image 579
david Avatar asked Jan 17 '15 15:01

david


3 Answers

Don't use require_once. That's causing that issue. You should use require or include

like image 130
Néstor Avatar answered Nov 13 '22 01:11

Néstor


There seems to be an error on some versions of the aws.phar file that causes this behavior and warning message.

Warning: require(phar://aws.phar/aws-autoloader.php): failed to open stream: phar error: invalid url or non-existent phar "phar://aws.phar/aws-autoloader.php" in /var/app/current/src/utils/AWS-SDK/aws.phar on line 3 Fatal error: require(): Failed opening required 'phar://aws.phar/aws-autoloader.php' (include_path='.:/usr/share/pear:/usr/share/php')

I was experimenting the same issue using aws.phar with version 2.7.17 of the AWS SDK for PHP

The solution that worked for me was to download and extract the aws.zip version of the AWS SDK for PHP and require aws-autoloader.php instead as described in the installation docs.

http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html#installing-via-zip

Some people reports success when using the 2.4.10 version of the AWS (aws.phar) but that is too old for my purposes.

https://pyd.io/f/topic/pydio-6-0-s3-plugin-phar-error/

like image 21
jhcaiced Avatar answered Nov 13 '22 02:11

jhcaiced


Try turning off opcache

  • add the following to /etc/php5/apache2/php.ini opcache.enable=0
  • restart apache service apache2 restart

This is a know issue at least with older versions of the aws.phar and there seems to be a general issue with phars and opc (formerly Zend Optimizer+)

like image 35
b7kich Avatar answered Nov 13 '22 02:11

b7kich