codeigniter - best practice library with many classes codeigniter - best practice library with many classes codeigniter codeigniter

codeigniter - best practice library with many classes


As Summer points out, they have handled this situation somewhat elegantly in CI 2.0 with the concept of Drivers.

With a Driver, you actually create a subdirectory within your 'libraries' directory that contains your 'super' class, and another directory for 'child' classes. Better visual representation of the structure...

enter image description here

This was taken from Here.

and once you have constructed your library, here is the documentation on how to use it.


In CI 2.0, there are drivers to handle this situation. Good luck!


In CodeIgniter 3.1.9 when you load a library file, all classes in this file are included into code.

Let's say in soaplibrary.php you have

class SoapLibrary {   public function someMethod(...class Test {   public function anotherMethod(...

In your controller you can do:

$this->load->library('soaplibrary');//now on you can do$this->soaplibrary->someMethod();//but also$test = new Test();$test->anotherMethod();

CodeIgniter attempts to call the constructor of class SoapLibrary, hence a class with that name must be in there.