CodeIgniter Forums
load library from different module in HVMC - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: load library from different module in HVMC (/showthread.php?tid=54711)



load library from different module in HVMC - El Forum - 09-21-2012

[eluser]scibuff[/eluser]
Hello, I have the following structure

Code:
/application
/application/modules/common/libraries/vo/vo_abstract
/application/modules/test/libraries/vo/my_vo

and I want my_vo to extends vo_abstract

what is the proper way to "include" vo_abstract inside the my_vo code. I definitely don't wanna do something like
Code:
include_once( APP_PATH.'modules/common/libraries/vo/vo_abstract.php' );
because the "modules" path may need to change. Can I somehow autoload ("include") the vo_abstract in CI (without instantiating it, as it is abstract)

Basically, what I'm after is how can one library in HMVC extend another library from a different module in the HMVC?

thank you.


load library from different module in HVMC - El Forum - 09-22-2012

[eluser]S-Vizion Software and Development[/eluser]
Why not just simply load it with

$this->load->library('modulename/libraryname');




load library from different module in HVMC - El Forum - 09-23-2012

[eluser]PhilTem[/eluser]
If one of your libs extends another lib from another module I'd say you didn't quite get the principle of HMVC which is modular separation. Separation includes separation of dependencies. Therefore, having a common/vo_abstract library being implemented by test/my_vo is not what HMVC enables you to have.

Either you should rethink the modular separation definition in regard to your files. Or search for
Code:
Modules::$locations
in your HMVC extension (I'm assuming you're using @wiredesignz HMVC). It will give you paths to all module location which you may loop through and load the library once you found the module's name (which should not be changed once it's named Wink )