![]() |
VOOZH | about |
The Configuration System is Maho's centralized mechanism for managing application settings from multiple sources. It handles loading, merging, caching, and accessing configuration data from XML files, the database, and environment variables. The system implements a cascading priority model where each source can override values from lower-priority sources.
For information about accessing configuration programmatically, see the core helper methods documented in this page. For command-line configuration management, see CLI Architecture. For admin interface configuration, see Admin Architecture.
The configuration system loads and merges settings from five primary sources in the following priority order (lowest to highest):
| Priority | Source | Location | Purpose |
|---|---|---|---|
| 1 (Lowest) | Base Configuration | app/etc/config.xml | System defaults and structure |
| 2 | Module Configuration | app/code/*/Module/etc/config.xml | Module-specific defaults |
| 3 | Local Configuration | app/etc/local.xml | Installation-specific settings |
| 4 | Database Configuration | core_config_data table | Admin-configurable values |
| 5 (Highest) | Environment Variables | $_ENV, $_SERVER | Runtime overrides |
Higher priority sources override values from lower priority sources for the same configuration path.
Title: Configuration Source Merging Logic
Sources:
The central configuration management class that coordinates loading, merging, caching, and accessing configuration data. It extends Mage_Core_Model_Config_Base and utilizes Maho\Simplexml\Config for XML manipulation.
Key Responsibilities:
init() app/code/core/Mage/Core/Model/Config.php272-297MAGE_MODULES constant app/code/core/Mage/Core/Model/Config.php15-71Class Location: app/code/core/Mage/Core/Model/Config.php13
Key Properties:
$_useCache app/code/core/Mage/Core/Model/Config.php80 - Controls cache logic usage.$_cacheSections app/code/core/Mage/Core/Model/Config.php89-95 - Defines splittable cache sections (adminhtml, crontab, install, stores, websites).$_options app/code/core/Mage/Core/Model/Config.php108 - Mage_Core_Model_Config_Options instance.$_prototype app/code/core/Mage/Core/Model/Config.php187 - Empty Mage_Core_Model_Config_Base for loading/merging.Title: Configuration Class Relationships
Sources:
Handles database operations for the configuration system, primarily reading from and writing to the core_config_data table.
Key Methods:
getResourceModel(): Retrieves the resource model instance app/code/core/Mage/Core/Model/Config.php234-240The configuration system initializes through Mage_Core_Model_Config::init().
Title: Configuration Initialization Sequence
Sources:
Maho uses a package-aware loading strategy. loadBase() scans for configuration files across the installation app/code/core/Mage/Core/Model/Config.php277
Merge Priority:
_prototype object app/code/core/Mage/Core/Model/Config.php187local.xml is specifically flagged via _isLocalConfigLoaded and a reference is kept in _refLocalConfigObject app/code/core/Mage/Core/Model/Config.php192-199loadModules().Maho optimizes performance by splitting the global configuration into sections.
The CACHE_TAG for configuration is CONFIG app/code/core/Mage/Core/Model/Config.php73 Sections defined in $_cacheSections include adminhtml, crontab, install, stores, and websites app/code/core/Mage/Core/Model/Config.php89-95
Section Splitting:
Sections with a recursion level of 1 (like stores and websites) are cached as individual entries to allow partial loading app/code/core/Mage/Core/Model/Config.php93-94
The Mage class provides static helpers for common configuration tasks.
| Method | Source | Description |
|---|---|---|
getStoreConfig($path, $store) | app/Mage.php277-280 | Returns value for specific store/path via Mage_Core_Model_Store::getConfig(). |
getBaseDir($type) | app/Mage.php253-256 | Returns system directory paths via Mage_Core_Model_Config_Options. |
getModuleDir($type, $module) | app/Mage.php265-268 | Returns absolute path to a module directory. |
In Maho, event observers can be declared directly in PHP code using the Maho\Config\Observer attribute. This modern approach replaces or supplements traditional config.xml observer declarations.
Implementation Examples:
Mage_CatalogInventory_Model_Observer uses attributes to listen to product load and save events app/code/core/Mage/CatalogInventory/Model_Observer.php44-121Mage_Tag_Model_Tag listens to product save/delete events in the adminhtml area app/code/core/Mage/Tag/Model/Tag.php194-208Mage_GiftMessage_Model_Observer handles conversion of quote items to order items app/code/core/Mage/GiftMessage/Model/Observer.php20-166Maho_AdminActivityLog_Model_Observer registers observers for admin authentication and model lifecycle events app/code/core/Maho/AdminActivityLog/Model/Observer.php48-133Mage_Catalog_Model_Product_Compare_Item handles customer login/logout bindings app/code/core/Mage/Catalog/Model/Product/Compare/Item.php164-178Mage_Weee_Model_Observer integrates with catalog price preparation and product edit forms app/code/core/Mage/Weee/Model/Observer.php20-171Sources:
Maho supports overriding configuration via environment variables using the MAHO_CONFIG__ prefix. This is handled by Mage_Core_Helper_EnvironmentConfigLoader app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php11-138
Schema: MAHO_CONFIG__<SCOPE>__<SECTION>__<GROUP>__<FIELD>
Examples:
MAHO_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME=MyStore app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php39MAHO_CONFIG__WEBSITES__BASE__GENERAL__STORE_INFORMATION__NAME=website app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php41MAHO_CONFIG__STORES__GERMAN__GENERAL__STORE_INFORMATION__NAME=store_german app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php43The overrideEnvironment method parses these variables and injects them into the XML configuration object app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php47-74
Configuration extends to specialized rendering subsystems:
Mage_Sales_Model_Order_Pdf_Abstract loads item renderers and totals from global/pdf/ configuration nodes app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php163-224Mage_Core_Model_App_Area manages the loading of configuration, events, and design parts for specific application areas (e.g., frontend, adminhtml) app/code/core/Mage/Core/Model/App/Area.php13-162Sources:
Refresh this wiki