7

I'm using EE Master Config along with Stash.

I know in Master Config that all the configs have been changed from $config[''] to $env_config['']

I noticed with Stash that Mark is using this format: $assign_to_config['']

You can see what I mean here in the dev branch of 2.3.6

I guess I'm wondering what is the different between $config and $assign_to_config

I usually just convert that over to the EE Master Config format though, now that I think of it, I've never really known what was the proper format or why the assign_to_config format exist in the first place.

15

$assign_to_config is an EE-native array used in the index.php file. Here's part of the comments EllisLab left for us to provide context:

The $assign_to_config array below will be passed dynamically to the config class. This allows you to set custom config items or override any default config values found in the config.php file. This can be handy as it permits you to share one application between more then one front controller file, with each file containing different config values.

The use of $env_config in our (Focus Lab's) config approach is to clearly display what is set in our config files vs what's set in index.php.

I guess I'm wondering what is the different between $config and $assign_to_config

Really the only difference between these two is that $config is set in the config.php file and $assign_to_config is set in the index.php file.

They all achieve the same goal though.

It's probably worth noting that if an array key exists in both the $config array and the $assign_to_config array, the latter will take precedent.

| improve this answer | |
  • So in the case of $assign_to_config in regards to Master Config should we just leave as is or convert to $env_config format or does it make no difference? Mark says this: "of course if you're using a custom config bootstrap file, add the config items there instead" – Natetronn Jan 11 '13 at 2:27
  • The original purpose of $assign_to_config was to enable multiple front-ends (or "front controller file") with these variables. You can technically change other config settings there, but I wouldn't suggest it. I say stick to config.php or your bootstrap of choice (config.master.php in this case). – Erik Reagan Jan 11 '13 at 2:28
  • I'm sticking with config.master.php of course though, should I change the format of the $assign_to_config to read as $env_config like everything else in EE Master Config or should it stay as is? (sorry, not sure I was clear at first.) – Natetronn Jan 11 '13 at 2:32
  • In theory either should work. For consistency I would recommend $env_config though. There's a section for 3rd party settings/overrides waiting for you :) – Erik Reagan Jan 11 '13 at 2:35
  • Awesome! So they are interchangeable in a sense (at least in context of this conversation.) Great, thanks for your help Erik! Oh, I'm aware of that 3rd party settings section and do in fact use it often :) – Natetronn Jan 11 '13 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.