Welcome Guest, Not a member yet? Register   Sign In
Dependency Management in Custom Services
#1

Hello
If I create a custom service, is it considered good practice to load models and other libraries/services directly within the service itself?Or is it better to pass all these instances from the controller when calling the service?

For example, if I have a service that requires 6 models and 3 other services or libraries, should I pass them all through the constructor?
Thank you [Image: smile.png]
Reply
#2

(This post was last modified: 03-21-2025, 10:50 PM by InsiteFX. Edit Reason: Added Services )

This may help you.

Lonnie Ezell - Dependecy Injection in CodeIgniter 4

Lonnie Ezell - Services in CodeIgniter 4
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB