CodeIgniter Forums
Using Dependency Injection - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Using Dependency Injection (/showthread.php?tid=83411)



Using Dependency Injection - mjamilasfihani - 09-24-2022

I want to use this thephpleague/container for my Dependecy Injection, any ideas how to implement it? Thank you and have a nice day!


RE: Using Dependency Injection - MGatner - 10-09-2022

Hey, not sure if you ever got a working solution? I didn't find anything current so I'm playing with in now: https://github.com/tattersoftware/forum/commit/54d4a8f2e57bd7fb658611f2f7c5bbb12c26a8d0

That's making a fresh container but you could use the same steps to override the app and provide a third-party container. Hope it helps!


RE: Using Dependency Injection - MGatner - 10-10-2022

I took a different route that I think is much simpler and better: using the container at the entry point (Routes) :https://github.com/tattersoftware/forum/compare/container2

The previous approach (handling it via an extended core app) is still here: https://github.com/tattersoftware/forum/compare/container