CodeIgniter Forums
How modules need load Config? - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Support (
+--- Thread: How modules need load Config? (/thread-74989.html)

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


I install 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’);