Why is it not recommended to use services in models and libraries? |
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? |
Messages In This Thread |
Why is it not recommended to use services in models and libraries? - by semprom - 11-04-2023, 03:25 AM
RE: Why is it not recommended to use services in models and libraries? - by ozornick - 11-04-2023, 05:39 AM
RE: Why is it not recommended to use services in models and libraries? - by semprom - 11-04-2023, 09:05 AM
RE: Why is it not recommended to use services in models and libraries? - by kenjis - 11-04-2023, 08:38 PM
RE: Why is it not recommended to use services in models and libraries? - by ozornick - 11-04-2023, 11:57 AM
|