ZF-2702: Fatal error: Class 'Zend_Pdf_Resource_Image' not found
Description
Get fatal error:
Fatal error: Class 'Zend_Pdf_Resource_Image' not found in [...cut...]/Zend/Pdf/Resource/Image/Jpeg.php on line 41
Which I would suspect is a loading error but everything is fine otherwise. The strangest part is that I can reproduce the error simply by doing:
new Zend_Pdf_Resource_Image();
Then I get that Jpeg error. Very strange. The class seems to load but then disappear?
The error originally occurred while trying to create a code coverage report using PHPUnit.
Comments
Posted by Jeffrey Sambells (jeffrey) on 2008-02-21T12:46:58.000+0000
After much testing I've determined this is the result of the require_once structure in the various files. It seems that if you don't require the object in the correct order it creates a "loop" where the require structure dies and the object is never really instantiated. The error actually occurs when you simply require the file! If you haven't loaded any other PDF stuff, just do this:
require 'Zend/Pdf/Resource/Image.php';
and you'll get the error. This happens because the require line do this:
Zend/Pdf/Resource/Image.php requires -> Zend/Pdf/Element/Object.php requires -> Zend/Pdf/ElementFactory.php requires -> Zend/Pdf/Element/Reference.php requires -> /Zend/Pdf/Element/Reference/Context.php requires -> Zend/Pdf/StringParser.php requires -> Zend/Pdf/Element/Object/Stream.php requires -> Zend/Pdf/Element/Stream.php requires -> Zend/Pdf.php requires -> Zend/Pdf/Resource/Image/Jpeg.php requires -> Zend/Pdf/Resource/Image.php
LOOP!!!
The last require doesn't actually happen since it already occurred (once) above but that means PHP then tries to parse Zend_Pdf_Resource_Image_Jpeg BEFORE Zend_Pdf_Resource_Image has been parsed.
The same applies to Tiff and such if you start requiring different files.
Posted by Wil Sinclair (wil) on 2008-03-31T16:12:00.000+0000
Please evaluate and categorize as necessary.
Posted by Alexander Veremyev (alexander) on 2008-07-26T04:57:11.000+0000
Zend_Pdf component objects are not intended to be used one by one.
In some places it's only "declaration", that this class needs som other(s). And it sometimes makes loops.
Actual require_once (and file parcing) order is defined by require_once tree (graph) starting from Zend_Pdf.
So you should always use:
to work with Zend_Pdf component.
Posted by Wil Sinclair (wil) on 2008-09-02T10:39:24.000+0000
Updating for the 1.6.0 release.