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 ?
require_once. That’s causing that issue. You should use
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.
Some people reports success when using the 2.4.10 version of the AWS (aws.phar) but that is too old for my purposes.
to solve the problem I’v installed the sdk using composer ! BTW it’s the recommended technique !
Try turning off opcache
- add the following to /etc/php5/apache2/php.ini
- restart apache
service apache2 restart
Make sure you declare all namespace usage at the top of the file before you do “require”. If you include files first, it can mess up the namespacing. This fixed the issue for me.