Welcome Guest, Not a member yet? Register   Sign In
Why is it not recommended to use services in models and libraries?
#1

Looking at the CI4's documentation about the Services (https://codeigniter4.github.io/userguide...e-services) there is a quote that says:

Quote:It is recommended to only create services within controllers. Other files, like models and libraries should have the dependencies either passed into the constructor or through a setter method.


Why it's not recommended to use the Services directly into the Model or Library? Wouldn't it be easier to just invoke the service and get the data rather than to make extra setter methods or pass it to the construct function?
Reply


Messages In This Thread
Why is it not recommended to use services in models and libraries? - by semprom - 11-04-2023, 03:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB