I'm potentially going to port Amazon FPS library for PHP to Drupal 7 and will utilize Libraries API if I do.
One peculiarity that I don't see covered in the examples (or that perhaps I can't recognize as being covered) is the scenario when a library, such as the Amazon FPS one that Amazon provides, doesn't really have a central class. By central class, I mean the Amazon Web Services SDK's sdk.class.php, for example, which presumably manages autoloading of any other class therein that would be needed.
If you look at amazon_fps, you'll see that I just included whichever class files I needed myself using a CTools-esque include routine. Are libraries like this candidates for Libraries API? Would I have to load all the files every time? Should I create multiple library entries or variants for the different files I may have to load? I figured I'd probably need to treat them as separate libraries but wasn't sure if I could do something a bit less conceptually weird (I mean, they are within the same folder, just different files depending on which subset of functionality I need).
Their included autoload sample uses __autoload, not spl_autoload_register
, hence I am hesitant to go that route.
I could also roll my own autoload class (I have my own versions of some of their classes anyway in amazon_fps, which, well, is another thing), so if you recommend going that route, I'll look into it.
Thanks.
Comments
Comment #1
tstoecklerIt seems that, if the library doesn't come with an autoloader itself we should utilize the Drupal autoloader?!
Either way, if I'm not mistaken this problem is covered in #1092270: Allow modules to have their library files autoloaded
Please mark this one duplicate if I'm correct.
That said, #1092270: Allow modules to have their library files autoloaded is far from having a viable approach so you're more than welcome to add your thoughts/examples there!
Comment #2
wizonesolutionsYep, that looks like my problem too. Marking duplicate and will join the fun in a couple days :)