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

5

8

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 ?

Chairborne answered 17/1, 2015 at 15:19 Comment(0)
B
5

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

Bullshit answered 13/8, 2015 at 19:9 Comment(2)
good point. i will try this. but How require_once effects . it shouldn't , right ?Chairborne
No, require_once calls only once the file: php.net/manual/es/function.require-once.php. what I've noticed is that you have to make continously callings to the aws bootstrap to make it works.Voletta
T
1

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/

Ticon answered 12/2, 2015 at 12:12 Comment(1)
Ya, I'm not sure what causes this but doing the sdk reference route fixed it for us. The weird part was that we had it running fine for months, didn't even change the .phar file, and then it broke.Microreader
I
1

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+)

Inapproachable answered 19/8, 2015 at 22:14 Comment(1)
The issue occurred for me when I moved my phar file to another location. I had to restart Apache after doing this because Apache cached its location. Simply running the apache restart command fixed the issue for me.Gonzalez
C
0

to solve the problem I'v installed the sdk using composer ! BTW it's the recommended technique !

Chairborne answered 22/1, 2015 at 10:37 Comment(0)
C
0

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.

Compress answered 8/9, 2015 at 21:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.