0

I try to work with ez Components and AWS PHP SDK at the same time.

I have a file called resize.php which is just handling resizing images using the ez Components ImageTransition tools.

I queue the image for resize in Amazon AWS SQS. If I load the AWS PHP SDK and ez Components in the same file, PHP always complains about not finding the ez Components classes.

Code looks something like this:

amazonSQS.php:

require 'modules/resize.php';
require 'modules/aws/sdk.class.php';

$sqs = new AmazonSQS();
$response = $sqs->send_message($queue_url, $message);

resize.php:

function resize_image($filename) {

$settings = new ezcImageConverterSettings(
    array(
        //new ezcImageHandlerSettings( 'GD',          'ezcImageGdHandler' ),
        new ezcImageHandlerSettings( 'ImageMagick', 'ezcImageImagemagickHandler' ),
    )
);

Error message:

Fatal error: Class 'ezcImageConverterSettings' not found in /home/www.com/public_html/modules/resize.php on line 10

If I call resize.php from another PHP file which has AWS not included, it works fine.

I load ezComponents like this:

require 'ezc/Base/ezc_bootstrap.php';

It is installed as a PEAR package.

Any idea someone?

aynber
  • 22,380
  • 8
  • 50
  • 63
David
  • 646
  • 1
  • 7
  • 27
  • I have never worked with AWS PHP SDK, but such behavior is usually caused by problems in classloader. I suppose, AWS PHP SDK has its own classloader, which cannot find ezComponents classes for some reason. – Kel Jan 08 '11 at 11:42
  • It seems like AWS is overwriting the autoloader of ezComponents. Do you have any idea how I can just load the specific class in ezComponents and ignore the autoloader? – David Jan 08 '11 at 12:12

1 Answers1

0

The PHP classes of Apache Zeta / eZ Components can be conveniently used from within your PHP script. You don't have to use any require or include statements for any of the Apache Zeta Components classes that you use, this is because of the integrated autoload mechanism which can locate the classes for you when you instantiate or use them otherwise.

There are three different ways of getting the autoload mechanism going:

  • Normal autoload, if you require a custom autoload function
  • Bootstrap file, if you only use Apache Zeta autoloading
  • SPL autoload, if you need to register several autoload functions

These 3 ways are fully documented here

Ronan
  • 4,311
  • 3
  • 19
  • 14