Welcome Guest, Not a member yet? Register   Sign In
Modules not loading config files
#1

I am wondering

https://forum.codeigniter.com/thread-78802.html

In the above topic I asked for the best practices for the loading of config files inside of a module? I have the module loaded in the autoload, I have the auto discovery option enabled. And I have the constants added to the Modules.php $aliases array in the main app config folder. 

Yet the constants are not beeing found. So I cannot use them in the application. I did find a work around but that means changing the main Constants.php by adding the following code.

PHP Code:
/**
 * --------------------------------------------------------------------
 * Include Modules Constants Files
 * --------------------------------------------------------------------
 */

if (file_exists(ROOTPATH'modules')) {
    
$modulesPath ROOTPATH.'modules/';
    
$modules scandir($modulesPath);

    foreach (
$modules as $module) {
        if (
$module === '.' || $module === '..') continue;
        if (
is_dir($modulesPath) . '/' $module) {
            
$constantsPath $modulesPath $module '/Config/Constants.php';
            if (
file_exists($constantsPath)) {
                require(
$constantsPath);
            } else {
                continue;
            }
        }
    }


I do however stil wonder if I missed something in the documentation. Or that is actualy a bug.
Reply


Messages In This Thread
Modules not loading config files - by ZoeF - 03-19-2021, 12:42 PM
RE: Modules not loading config files - by kenjis - 03-19-2021, 06:44 PM
RE: Modules not loading config files - by ZoeF - 03-19-2021, 08:13 PM
RE: Modules not loading config files - by ZoeF - 03-20-2021, 02:05 PM
RE: Modules not loading config files - by kenjis - 03-20-2021, 05:55 PM
RE: Modules not loading config files - by ZoeF - 03-20-2021, 06:01 PM
RE: Modules not loading config files - by ZoeF - 03-21-2021, 07:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB