Welcome Guest, Not a member yet? Register   Sign In
Using the new library drivers
#1

[eluser]sheldonnbbaker[/eluser]
I grabbed the 'tip' tag from bitbucket and am playing with some of the new features.

Not sure how to use the library drivers though - the explanation over at Elliot's blog is kinda confusing.

If I have a cache library for example, and I want to be able to call $this->cache->get() from my controller and then have my main cache library (libaries/cache.php) call the appropriate driver (APC or Memcache driver) - how would I do that?

Thanks Smile
#2

[eluser]tomdelonge[/eluser]
I don't think it means that kind of driver. I've been wrong before though. I think it's more of an abstraction layer where you make a library that can have more specific ones underneath it. The example they use is the javascript "driver". It could then have jquery or prototype or something else underneath it. The "driver" would tie common functionality between child libraries.

I think that's right. Not sure though.

Hope it helps.
#3

[eluser]InsiteFX[/eluser]
From the CodeIgniter 2.0 User Guide:

Drivers are a special type of Library that has a parent class and any number of potential child classes. Child classes have access to the parent class, but not their siblings. Drivers provide an elegant syntax in your controllers for libraries that benefit from or require being broken down into discrete classes.

Drivers are found in the system/libraries folder, in their own folder which is identically named to the parent library class. Also inside that folder is a subfolder named drivers, which contains all of the possible child class files.

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB