load class and not instantiate - 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: load class and not instantiate (/showthread.php?tid=41676) |
load class and not instantiate - El Forum - 05-13-2011 [eluser]uniq[/eluser] Hello, How to load class in CI 2 and not instantiate it? P.S. in CI 1.7+ it was simple by passing second param to load_class function load class and not instantiate - El Forum - 05-14-2011 [eluser]toopay[/eluser] As long as i aware of CI upgrade from 1.7.x to 2.x, there is nothing change at how loader class works, related with your issue above. load class and not instantiate - El Forum - 05-14-2011 [eluser]uniq[/eluser] FYI CI 1.7.x system/codeigniter/common.php Code: * @access public CI 2.x system/core/common.php Code: * @access public and the problem is that I have lib with private __construct: Code: private function __construct() of course I can use requered_once but then I have to work with include paths ... load class and not instantiate - El Forum - 05-14-2011 [eluser]toopay[/eluser] Thanks for remind me that i missread your thread (what i've looked up is loader class, file under system/core/Loader.php). Back to your issues, what about extending Common.php? PS : you can wrap your code, on code tags Code: // Remove any spaces load class and not instantiate - El Forum - 05-14-2011 [eluser]uniq[/eluser] thanks for [ code] I would extend it if there is no way to do it with default CI load class and not instantiate - El Forum - 01-19-2012 [eluser]ColonelChlorine[/eluser] Bit of an old thread, but thought I'd throw my 2c in because I ran into the same issue creating my own library which I didn't want CI to interfere with. I didn't try extending the Common.php file (I don't even think you can because it's just a collection of functions) ... however I wrote my own loader. Threw it in as a helper. It basically accepts a class name, looks for it in the APPPATH."classes" folder and does a require_once(). That's not far off how CI does it's loader, except it does all the singleton + instantiation crap as well. Works like a charm for me. |