CodeIgniter Forums
Where to place Services? - 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: Where to place Services? (/showthread.php?tid=76501)



Where to place Services? - Zark - 05-18-2020

I am wondering what's the best practice or convention for a location wherein to store custom 'Services'?
E.g. Authentication service.

If I may suggest a change to docs, adding in this info under Services would be helpful.


RE: Where to place Services? - dave friend - 05-18-2020

The docs cover it pretty well already. Put your custom services stuff in /app/Config/Services.php


RE: Where to place Services? - Zark - 05-19-2020

(05-18-2020, 08:24 PM)dave friend Wrote: The docs cover it pretty well already.  Put your custom services stuff in /app/Config/Services.php

Thanks for the reply, Dave. The docs cover how to register or define Services. What I am asking is where should one store the Class files in terms of best practices?


RE: Where to place Services? - dave friend - 05-19-2020

(05-19-2020, 04:07 AM)Zark Wrote: What I am asking is where should one store the Class files in terms of best practices?

I prefer to keep the configuration files in app/Config/. The class files can be anywhere which is a nice change from CI v3. That said, I put them in app/Libraries more often than not. If multiple files are involved a subfolder to app/ is used, e.g. app/MyModule/.