Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Integration with 3rd party PHP OOP classes & require_once Behaviour clarification
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

Hi all,

I have a 3rd party PHP class (present in directory placed under../lib/POC/include) that I need to use in magento. In my calling magento PHP code, Mage.php includes the lib path (.../lib) using php function ‘set_include_path’ (see . My problem in using the PHP class is

// Filename class.Chat.inc inside directory lib/POC/include
 
require_once(POC_BASE.'/config.inc.php');
 
require_once(
POC_INCLUDE_PATH.'/adodb/adodb.inc.php');
require_once(
POC_INCLUDE_PATH.'/class.Language.inc');
require_once(
POC_INCLUDE_PATH.'/class.Chatter.inc');
 
class 
POC_Chat {
  
...

3rd party PHP class has require_once statements on top of the file containing the class. So if I use this class, will the require_once statements also come over?? Else how do I handle such a situation and use these 3rd party classes?

Thanks!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

What do you mean with “come over”? The required files will be present, yes. Shouldn’t be a problem as long as the classes don’t collide with Magento classes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

was doubtful if POC_Chat alone is loaded or if the entire file containing POC_Chat is loaded. Was worried because POC_Chat requires the files included via require_once ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

tested this and found that the entire file that contains the class gets loaded ...so no issues…

Which means in my example, the require_once statement are also executed when POC_Chat class gets loaded which is good enough for me.

Thanks!!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top