Welcome Guest, Not a member yet? Register   Sign In
Autoloading of configs in cascade

Yeah, there's a tricky situation of overriding the functions within Common.php. For many things you can override within app/Config/Boot/{environment}.php (replacing environment for the name of the current environment, like development, testing, etc). But the Common.php file is needed prior to loading those boot files, unfortunately.

You don't want to bypass loading a core file. For this example, you would do a two-step process:

1. Create a new class MyConfig (or whatever) that extends CodeIgniter\Config\Config class.
2. Update the get() method to work like you want it to.
3. Use public/index.php to load a file that contains your config() function.

Don't consider public/index.php as a framework file - that's for you to modify if needed. Of course you're responsible if you break things at that point Smile

All of the functions in Common.php will first check to make sure that function doesn't exist before trying to define it. So your custom config() function will be used throughout the framework now.

This does appear to be an area that needs a little work. I think checking for the existing of an app/Config/Functions.php file or something in the bootstrap would do it. Developers can modify that file then without breaking anything. So - thanks for bringing it up! I'll make an issue for that now.

Messages In This Thread
Autoloading of configs in cascade - by JoellSVK - 07-21-2019, 01:32 PM
RE: Autoloading of configs in cascade - by kilishan - 07-22-2019, 10:13 AM

Theme © iAndrew 2016 - Forum software by © MyBB