The IoC container is kind of a complex subject for me, and coming from a Codeigniter background (where you just could copy and paste a library and it worked by including it with include_once()
), it's a difficult concept to wrap my head around.
I'm trying to use Graufette for my project and I think I need to use an IoC Container so I can load the library and use it. The thing is that:
- I don't know where to put the library files
- I don't know where to put the code that registers the IoC container
- I don't know how to load libraries outside the
libraries
folder
According to Mr. Dayle Rees, you simply register the container in application/start.php and call it in your controllers with IoC::resolve()
. The thing is that he doesn't specify where do you put the files to register (or if you can put the IoC::register()
code elsewhere).
I don't go blindly and say "in the libraries folder" because, as I've seen, they get loaded automatically (and can be accessed statically). For Gaufrette, and other libraries (like SwiftMailer, but that's another story because there's a bundle for that), that is not the case.
Where can I put those files and load them with the IoC Container? Is it even necessary to do that?