Magento 1.9 Integration – How to Add Third-Party PHP Library Not Following Magento Standards

externalmagento-1.9

I would like to use an external library (PayPal SDK to be specific) in /lib of Magento. I will use it in a new module.

I've put lib/PayPal folder inside a new folder /lib/PayPal, but the class names doesn't follow Zend standards (i.e.: the classes has single names, like "class Address extends… instead of PayPal_Api_Address", so Magento doesn't autoload them.

I see I can use set_include_path to add the new path for being used in Magento, but I'm not sure this is the best approach.

If it is, what would be the best place to do it without having to add it inside each class of my new module?

Any help is appreciated.
Thank you very much.

Best Answer

Depending on the library, you may be able to use the very handy PSR-0-Autoloader Hackathon module.

https://github.com/magento-hackathon/Magento-PSR-0-Autoloader

The installation is pretty straightforward and there is a simple directive you will add to local.xml to get it working for your library.

Related Topic