Search code examples
phpcomposer-phppearautoload

Autload with composer from a file with classmaps


In my project I use ezc components from PEAR. I want to move all dependency to composer so for it I've found https://github.com/lortnus/ezc. It's great, but I have a one problem - autoloading. There is an autoload folder with classmaps, but I don't have any clue how I can make composer's autoload to use them. Any idea how to do it?

EDIT

I've found two possible ways how to autoload these classes: - fork lortnus/etc and add autoload in composer.json - add autoload in composer.json in my project

Setting a classmap autoloader for all ezc classes will produce a huge autoload_classmap file. I'm not sure, but it can hit a performance a bit. Because of that I take a second approach and it looks like this:

"classmap": [
    "vendor/lortnus/ezc/Base/src",
    "vendor/lortnus/ezc/Mail/src"
]

and instead of creating a classmap for whole ez Components I end up of with a classmap with classes that I need. I don't like setting path to vendor folder, but think that's the best possibility here.


Solution

  • If you do want to go through the hassle (or probably not) of upgrading, the current officially release packages of those "ezComponents" you are using are hosted at Github under their newer name "Zeta Components".

    The mail component in particular can be loaded with Composer via their name "zetacomponents/mail". Autoloading is included. They still seem to do some maintenance, because after the 2009 release of version "1.7" there is already a 2014 release of "1.8 beta"

    I cannot evaluate the amount of work required to upgrade your use of the older version to the newer one, but with only the mail component involved, this probably is a work worth doing.