I am creating some magento module, and I need to use some 3rdParty classes "ThiredPartyClassA" and "ThiredPartyClassB" that are in an external file "thirdPartyCode.php".
where should I place the file thirdPartyCode.php ? and how should I refer (require_once) to if so that I can use it within one of my Action handlers ?
Thanks, Eyal
I ended up creating a lib directory under my modules main directory. It seemed to be the "best of both worlds".
$ExternalLibPath=Mage::getModuleDir('', 'My_Module') . DS . 'lib' . DS .'EXTERNALLIB.php';
require_once ($ExternalLibPath);
You can require files in PHP just as you could without Magento, so you can actually use require_once
if need be. If you want to keep your code cleaner, you may want to put it into the /lib
folder in Magento since it is a system library. I am not sure if this is in the default include path, so you may have to fiddle with the require.
For cleanliness, you may also want to make a wrapper around this code and use Magento models/helpers to manipulate them.
Hope that helps!
Thanks, Joe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With