#StackBounty: #magento-1.9 #composer How to load a classmap[ped] Composer class (packagist) in Magento 1?

Bounty: 50

I’ve installed and deployed magento-hackathon/magento-composer-installer in my Magento 1.9 and I am trying to add and use mpdf/mpdf (composer packagist) in a controller.

This package contains a classmapped file

"autoload": {
    "classmap": [

Which is called in another component.

$this->parsers[$fn] = new fpdi_pdf_parser($fn);

And then Magento gives me the error

Warning: include(Fpdi/Pdf/Parser.php): failed to open stream: No such
file or directory in
/../mymagento/lib/Varien/Autoload.php on line 94

The Mage.php seems to be patched properly, and I also tried to do composer dumpautoload.

Some facts and findings:

  • If I create a /newfile.php (on the root folder, with not triggering Magento), include autoload.php, and call the method, it works.
  • If I disable developer mode it works (and the warning is logged).
  • If I change the Varien/Autoload.php and add an if(stream_resolve_include_path($classFile)) (as suggested here) before returning the include, it works (but I would override a core file).
  • It seems that when composer autoload resolves fpdi_pdf_parser it makes a require_once to ‘pdf_parser.php‘ and at this stage Mage autoload is triggered instead of Composer’s autoload.

Am I missing something? Any help is appreciated.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.