config.xml vs local.xml

17

¿Cuál es la diferencia entre app / etc / config.xml y app / etc / local.xml ?

Siento que algunas configuraciones están duplicadas. Siempre tengo que tratar con local.xml, entonces, ¿cuál es el propósito de tener todas esas otras cosas en config.xml y cuándo se usa?

velo
fuente

Respuestas:

15

config.xml y local.xml se cargan juntos, junto con cualquier otro archivo xml que coloque app/local. Están cargados enMage_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.

Marius
fuente
4
Also during upgrade config.xml will be overwritten and local.xml will not be. And finally local.xml is actually loaded twice, at start and end of config parsing. Since it is all merged in one config object, anything you put in local.xml will override any other config in any module.
Petar Dzhambazov
4
@PetarDzhambazov "at end of config parsing" is not entirely correct/clear, as the values from core_config_data are parsed and merged in after local.xml.
benmarks