What is the difference between app/etc/config.xml and app/etc/local.xml?
I feel like some configurations are duplicated. I always have to deal w/ local.xml, so what is the purpose of having all that other stuff in config.xml and when is it used?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityconfig.xml and local.xml are loaded together, along with any other xml file you place in app/local
. They are loaded in Mage_Core_Model_Config::loadBase()
public function loadBase()
{
$etcDir = $this->getOptions()->getEtcDir();
$files = glob($etcDir.DS.'*.xml');
$this->loadFile(current($files));
while ($file = next($files)) {
$merge = clone $this->_prototype;
$merge->loadFile($file);
$this->extend($merge);
}
if (in_array($etcDir.DS.'local.xml', $files)) {
$this->_isLocalConfigLoaded = true;
}
return $this;
}
Magento will work if you move the contents of config.xml to local.xml and remove entirely config.xml.
This separation exists for a reason.
config.xml contains (let's call them) settings that do not depend on the environment where Magento is installed.
local.xml contains environment dependent settings: DB connection, cache engine, encryption key, session handler.
This way a part of the settings can be versioned (config.xml) and you only have a small file depending on the environment.
core_config_data
are parsed and merged in after local.xml.