Reputation: 302
bit of a theory question this one. I would like to write my own library for codeigniter. It's going to be from connecting to different british Accountancy packages via API's. If it were a single package I was writing it for then I could create the library easily, however, it will be multiple. I intend to load the library as follows:
$params = array('package' => 'quickbooks');
$this->load->library('accountancy', $params);
Through my research so far, each API does not offer the same functionality therefore my library will have to be able to disable/enable functions based on the selected package. Also, the api's are different so each function will have to work differently based on the selected package also.
Firstly, is a library the best course of action?
Does anyone have any tutorials they can point me to or anything else to help?
Not looking for someone else to write it for me, just looking to be pointed in the right direction.
Thanks
Upvotes: 1
Views: 69
Reputation: 8964
There are probably multiple solutions.
If what you need to accomplish can be conceived as an abstraction layer (which means that, regardless of which accounting package you're using, you use the same functions to get things done) then using the "Drivers" approach might work.
First, check out the CI documentation for Using CodeIgniter Drivers.
CI uses the driver pattern for the cache, database and session classes. Studying that source code may prove helpful. Cache.php might be the easiest to get your head around to start with.
Via Google I found one Codeigniter Drivers Tutorial and I'm pretty sure the Stack Overflow has some info too.
Here's another example of using CI drivers.
I confess that I didn't look at either tut very closely. So I'm not certain how helpful they will be.
Upvotes: 2