-- bytte <[email protected]> wrote
(on Friday, 10 April 2009, 03:40 PM -0700):
> But then I get these errors everywhere:
> 
> Warning:
> require_once(/Users/xxx/Sites/zf-test/library/dompdf-0.5.1/include/zend_config_ini.cls.php)
> [function.require-once]: failed to open stream: No such file or directory in
> /Users/xxx/Sites/zf-test/library/dompdf-0.5.1/dompdf_config.inc.php on line
> 194
> 
> And
> 
> Fatal error: require_once() [function.require]: Failed opening required
> '/Users/xxx/Sites/zf-test/library/dompdf-0.5.1/include/zend_config_ini.cls.php'
> (include_path='.:../library/:../application/models:../application/forms:../library/dompdf-0.5.1:.:/opt/local/lib/php')
> in /Users/xxx/Sites/zf-test/library/dompdf-0.5.1/dompdf_config.inc.php on
> line 194
> 
> What am I doing wrong?

Well, *you* aren't -- the authors of DOMPDF are by using require_once in
their autoloader (that's a no-no; autoloaders should be chainable, and
thus fail gracefully). Create your own autoloader function for their
stuff that's a bit less restrictive. For example, try the following in
your bootstrap:

    function My_DOMPDF_Autoload($class)
    {
        $filename = DOMPDF_INC_DIR . '/' . mb_strtolower($class) . '.cls.php';
        if (Zend_Loader::isReadable($filename)) {
            return include_once $filename;
        }
        return false;
    }

    require_once 'Zend/Loader.php';
    spl_register_autoload('My_DOMPDF_Autoload');
    Zend_Loader::registerAutoload();

and that should work.

> Matthew Weier O'Phinney-3 wrote:
> > 
> > -- bytte <[email protected]> wrote
> > (on Friday, 10 April 2009, 09:28 AM -0700):
> >> 
> >> Thanks. But I'm confused. Early on in my bootstrap I have this code:
> >> 
> >> set_include_path('.' . PATH_SEPARATOR . '../library/'
> >> . PATH_SEPARATOR . '../application/models'
> >> . PATH_SEPARATOR . '../application/forms'
> >> . PATH_SEPARATOR . '../library/dompdf-0.5.1'
> >> . PATH_SEPARATOR . get_include_path());
> >> include "Zend/Loader.php";
> >> Zend_Loader::registerAutoload();
> >> 
> >> Then where exactly do I need to insert this spl_autoload_register()
> >> function?
> > 
> > Before the Zend_Loader::registerAutoload() call.
> > 
> >> If I do it in my controller where I create the pdf, the pdf gets created
> >> but
> >> it starts with a lot of warnings because a lot of files in the DOMPDF
> >> file
> >> structure weren't found. Such as:
> >> 
> >> Warning: Zend_Loader::include_once() [function.include]: Failed opening
> >> 'Style.php' for inclusion
> >> (include_path='.:../library/:../application/models:../application/forms:../library/dompdf-0.5.1:.:/opt/local/lib/php')
> >> in /Users/xxx/Sites/zf-test/library/Zend/Loader.php on line 83
> >> 
> >> If I do it in my bootstrap just before Zend_Loader::registerAutoload(),
> >> all
> >> my other code doesn't work anymore as it looks like the DOMPDF autoloader
> >> is
> >> used to load all the ZF classes. Here's the warnings I get then:
> >> 
> >> Warning:
> >> require_once(/Users/xxx/Sites/zf-test/library/dompdf-0.5.1/include/zend_config_ini.cls.php)
> >> [function.require-once]: failed to open stream: No such file or directory
> >> in
> >> /Users/xxx/Sites/zf-test/library/dompdf-0.5.1/dompdf_config.inc.php on
> >> line
> >> 194
> >> 
> >> Could you provide me with some more information? It would be really
> >> helpful.
> >> 
> >> 
> >> 
> >> 
> >> 
> >> Mon Zafra wrote:
> >> > 
> >> > spl_autoload_register('DOMPDF_autoload');
> >> > 
> >> > Make sure that loader is registered late in the stack because it does a
> >> > require_once, meaning it will throw a fatal if it fails and will
> >> prevent
> >> > the
> >> > other autoloaders from trying to load the class.
> >> > 
> >> >    -- Mon
> >> > 
> >> > 
> >> > On Fri, Apr 10, 2009 at 9:22 PM, bytte <[email protected]>
> >> wrote:
> >> > 
> >> >>
> >> >> I'm using DOMPDF in a project of mine and I was wondering how I can
> >> call
> >> >> DOMPDF's autoload function so it can function together with the one
> >> from
> >> >> Zend Framework.
> >> >>
> >> >> Here's what DOMPDF says:
> >> >>
> >> >> /**
> >> >>  * DOMPDF autoload function
> >> >>  *
> >> >>  * If you have an existing autoload function, add a call to this
> >> function
> >> >>  * from your existing __autoload() implementation.
> >> >>  *
> >> >>  * @param string $class
> >> >>  */
> >> >> function DOMPDF_autoload($class) {
> >> >>  $filename = mb_strtolower($class) . ".cls.php";
> >> >>  require_once(DOMPDF_INC_DIR . "/$filename");
> >> >> }
> >> >>
> >> >> How exactly can I make it work together with the ZF?
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Calling-external-autoload-function-%E2%80%93-how-to--tp22987919p22987919.html
> >> >> Sent from the Zend Framework mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> > 
> >> > 
> >> 
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/Calling-external-autoload-function-%E2%80%93-how-to--tp22987919p22990711.html
> >> Sent from the Zend Framework mailing list archive at Nabble.com.
> >> 
> > 
> > -- 
> > Matthew Weier O'Phinney
> > Software Architect      | [email protected]
> > Zend Framework          | http://framework.zend.com/
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Calling-external-autoload-function-%E2%80%93-how-to--tp22987919p22995726.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
Software Architect      | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to