CodeIgniter Forums
How modules need load Config? - 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: How modules need load Config? (/showthread.php?tid=74989)



How modules need load Config? - XTAZ - 12-04-2019

Hello!

I install https://github.com/benedmunds/CodeIgniter-Ion-Auth/tree/4/ with composer, now I want edit IonAuth config file, but i not want edit file in vendor directory, because it not tracked with Git.

IonAuth loads config by function config('IonAuth\\Config\\IonAuth');
In autoload I setted IonAuth to COMPOSER_DIR . '/benedmunds/codeigniter-ion-auth'.

How need IonAuth loads config with two conditions:
1. If config file \App\Config\IonAuth.php exists - load it
2. If not exists - load from \IonAuth\Config\IonAuth.php

Now CI4 check config files only App and System dir.
Now if use config('IonAuth\\Config\\IonAuth') - CI4 dont see \App, but if use config('\\Config\\IonAuth'), CI4 dont see \IonAuth if \App file not exists


RE: How modules need load Config? - MGatner - 12-04-2019

You want the config() command, that does precisely that.

$config = config(‘IonAuth’);