Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 2 - Drivers :: example
#1

[eluser]OliverHR[/eluser]
Hello everybody,

As seems there is not out there any example about the new feature of CodeIgniter 2 "Drivers". I decided to post an small and simple (very small, very simple) Example.

Zip file on Mediafire(because I can't upload to forum):
http://www.mediafire.com/file/yo1xxy512l...xample.zip ---OBSOLETE LINK---

Any comments welcome.

you can get codeigniter 2 in Bitbucket clicking on get source.

http://bitbucket.org/ellislab/codeigniter
#2

[eluser]OliverHR[/eluser]
Code uploaded to Github:

http://github.com/oliverhr/CI2_Drivers_example
#3

[eluser]InsiteFX[/eluser]
Thanks!

Will take a look at it later.

InsiteFX
#4

[eluser]OliverHR[/eluser]
Great, by the way the README file is empty, was a test for git repo.
#5

[eluser]coldclimate[/eluser]
Just what I was looking for!
#6

[eluser]Vheissu[/eluser]
Lol. I posted a topic just before asking about drivers, fantastic, thank you. Although I did some digging and was saddened to see it's not true driver capability, but more of an extended version of Codeigniter libraries Sad

Still will be beneficial to my auth library though.
#7

[eluser]Eric Barnes[/eluser]
Here is one I did that was designed to minify and compress assets - https://github.com/ericbarnes/ci-minify Might be of help to someone as well.
#8

[eluser]Vheissu[/eluser]
[quote author="Eric Barnes" date="1297460988"]Here is one I did that was designed to minify and compress assets - https://github.com/ericbarnes/ci-minify Might be of help to someone as well.[/quote]

Very helpful. I understand how they work and how to make drivers, etc. The one thing I don't understand is how you create functions in the main driver class that loads the child drivers to make it a true driver system where drivers implement the main driver abstract class and must implement those methods.

I posted a topic asking how an auth system could use the drivers and how child classes would feed back into that. Would I just define the needed methods and then the drivers can overload those methods their own logic?

Also, to use the default passwords that come with WolfAuth, make your config encryption key the following: "kjgkds09gs8d09g8s092523523758237" without the quotes obviously. If not, you'll have to create new accounts to suit your encryption key.
#9

[eluser]Eric Barnes[/eluser]
[quote author="Vheissu" date="1297495752"]
Very helpful. I understand how they work and how to make drivers, etc. The one thing I don't understand is how you create functions in the main driver class that loads the child drivers to make it a true driver system where drivers implement the main driver abstract class and must implement those methods.
[/quote]

A good example of this is the new Cache driver. Check out the main cache file and you can see how it is calling the child from the parent:
Quote: public function get($id)
{
return $this->{$this->_adapter}->get($id);
}

In my mind this should really be an interface so you can guarantee the drivers implement the same methods or at least the methods you are expecting. But I think it was not set up this way so it would be the most flexible.
#10

[eluser]Vheissu[/eluser]
[quote author="Eric Barnes" date="1297564786"][quote author="Vheissu" date="1297495752"]
Very helpful. I understand how they work and how to make drivers, etc. The one thing I don't understand is how you create functions in the main driver class that loads the child drivers to make it a true driver system where drivers implement the main driver abstract class and must implement those methods.
[/quote]

A good example of this is the new Cache driver. Check out the main cache file and you can see how it is calling the child from the parent:
Quote: public function get($id)
{
return $this->{$this->_adapter}->get($id);
}

In my mind this should really be an interface so you can guarantee the drivers implement the same methods or at least the methods you are expecting. But I think it was not set up this way so it would be the most flexible.[/quote]

Ah, very interesting. Thank you for that Eric! So you can call the child from the parent, I was wondering if you could because everywhere else I read it said that you couldn't. Didn't really dig too much, but _adapter will be most useful definitely.

Is adapter the currently selected child driver? So if I have an auth class and a Facebook driver, and I use the Facebook driver, _adapter will be the Facebook class? How hard do you think it would be to extend native CI drivers capability and make it an interface or abstract class for child drivers to implement?

Is the drivers library even extendible? It might be more trouble than it's worth, I guess the current way they work is fine, it's better than just using a standard library at least.




Theme © iAndrew 2016 - Forum software by © MyBB