CodeIgniter Forums
Config files in modules - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Config files in modules (/showthread.php?tid=78802)



Config files in modules - ZoeF - 03-12-2021

Hello

I am wondering what the best practices are for adding specific modules configs. I followed the documentation but it seems I am either missing something or it does not work all the time.

In app > Config > Modules.php you can add $aliases. Yet when I add constants to this array it does not get loaded.

So in retrospect what is the best way of adding configs that they are sertan to be loaded.


RE: Config files in modules - InsiteFX - 03-12-2021

The modules namespace should be added to CodeIgniters Config/Autoload.php


RE: Config files in modules - ZoeF - 03-13-2021

Yes I know and I also did that. Stil the Constants.php is not beeing loaded.


PHP Code:
'Modules/Admin'        => ROOTPATH 'modules/admin'// The Admin Module
'Modules/Users'        => ROOTPATH 'modules/users'// The User Module 



Or is it required to also add the modules Config path to this list?


RE: Config files in modules - InsiteFX - 03-13-2021

I use a Config file for all my constants and place it in the modules folder under config then I
can load it myself.

But if you add your constants to the Config/Constants.php file they should load.


RE: Config files in modules - ZoeF - 03-13-2021

What I did is the following

>modules >Admin >Config -Constants.php

added my required constants

But when I try to use them in the specific module
ErrorException
Use of undefined constant ADMIN_TEST - assumed 'ADMIN_TEST'