Library as Singleton in Codeigniter?
问题 I've created a custom library using singleton pattern. Why by this way? because I need to be able to call my functions without $this-> reference, for example, I could execute the code below: function foo() { MyLibrary::instance()->foo(); } then I could call my functions in controllers like this: function foo(); instead of $this->mylibrary->foo(); I am in trouble because CodeIgniter try to instantiate my library when the best way to do is "read" the static instance. Why I need to do this? My