Rican7
Rican7

Reputation: 1142

Including a PHAR that packages an existing class

I have a project that currently uses Guzzle (which is loaded [as a .phar] by an explicit "require_once" in a bootstrap file).

I have been trying to add the AWSSDKforPHP from Amazon, so that I can easily handle uploads to Amazon S3. Unfortunately, when I try to include the package (also packaged as a .phar file), PHP throws a nasty error:

 PHP Fatal error:  Cannot redeclare class Symfony\\Component\\ClassLoader\\UniversalClassLoader in phar:///usr/share/php/AWSSDKforPHP/aws.phar/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php on line 62

I have already turned off (completely) APC, as I've seen APC cause some require/include headaches before.

I doubt that PHP would have such an awkward limitation of only being able to include a package with a dependency once. ... But I could be wrong.

Upvotes: 0

Views: 580

Answers (1)

Michael Dowling
Michael Dowling

Reputation: 5266

Looking at both of these libraries' phar stubs, I'm not sure why it's conflicting on the require_once of the UniversalClassLoader. The good news is that the phar provided by the AWS SDK for PHP 2 also includes the Guzzle library, so you only need to include the aws.phar in your application.

Upvotes: 1

Related Questions