![]() |
Where to put classes of business logic? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Where to put classes of business logic? (/showthread.php?tid=11837) Pages:
1
2
|
Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]xwero[/eluser] It's not the 'correct' usage of helpers but no harm no foul. The documentation is a guideline for using the framework. You use the tools that are available to the best of your creativity ![]() Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]wiredesignz[/eluser] You can also load the class as a plugin, it will not be instaniated by CI Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]Référencement Google[/eluser] I personally see nothing wrong including them like this in a controller: Code: require_once(APPPATH.'libraries/Someclass.php'); And them instantiate them using conventional PHP. Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]xwero[/eluser] That was my second suggestion but meglio wants to do it CI wise i guess. Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]Référencement Google[/eluser] then he can include in from a MY_Controller there would be nothing wrong about that Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]Dready[/eluser] Hello, that's really not a correct usage of helpers. I see two more elegant solutions : Autoload your libraries with autoload functions Perhaps you already know it, something like : helpers/autoload_helper.php Code: function __autoload($class_name) { And in config/autoload.php Code: $autoload['helper'] = array('autoload'); Create a factory class If you have many business classes, using a factory pattern can help you to have a common way to load all libraries. libraries/factory.php Code: class factory { in controllers : Code: $this->load->library('factory'); Where to put classes of business logic? - El Forum - 09-25-2008 [eluser]Référencement Google[/eluser] I like the idea of a factory class, very smart Dready! |