VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/3.3-configuration-system

⇱ Configuration System | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

Configuration System

Purpose and Scope

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.


Configuration Sources and Priority

The configuration system loads and merges settings from five primary sources in the following priority order (lowest to highest):

PrioritySourceLocationPurpose
1 (Lowest)Base Configurationapp/etc/config.xmlSystem defaults and structure
2Module Configurationapp/code/*/Module/etc/config.xmlModule-specific defaults
3Local Configurationapp/etc/local.xmlInstallation-specific settings
4Database Configurationcore_config_data tableAdmin-configurable values
5 (Highest)Environment Variables$_ENV, $_SERVERRuntime overrides

Higher priority sources override values from lower priority sources for the same configuration path.

Title: Configuration Source Merging Logic


Sources:


Core Classes

Mage_Core_Model_Config

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:

Class Location: app/code/core/Mage/Core/Model/Config.php13

Key Properties:

Title: Configuration Class Relationships


Sources:

Mage_Core_Model_Resource_Config

Handles database operations for the configuration system, primarily reading from and writing to the core_config_data table.

Key Methods:


Configuration Loading Process

Initialization Flow

The configuration system initializes through Mage_Core_Model_Config::init().

Title: Configuration Initialization Sequence


Sources:

XML Merging

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:

  1. Files are merged into the _prototype object app/code/core/Mage/Core/Model/Config.php187
  2. local.xml is specifically flagged via _isLocalConfigLoaded and a reference is kept in _refLocalConfigObject app/code/core/Mage/Core/Model/Config.php192-199
  3. Module configurations are loaded via loadModules().

Configuration Caching

Maho optimizes performance by splitting the global configuration into sections.

Cache Sections and Tags

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


Accessing Configuration

Reading Values

The Mage class provides static helpers for common configuration tasks.

MethodSourceDescription
getStoreConfig($path, $store)app/Mage.php277-280Returns value for specific store/path via Mage_Core_Model_Store::getConfig().
getBaseDir($type)app/Mage.php253-256Returns system directory paths via Mage_Core_Model_Config_Options.
getModuleDir($type, $module)app/Mage.php265-268Returns absolute path to a module directory.

Advanced Features

Attribute-Based Observer Configuration

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:

Sources:

Environment Variable Overrides

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:

The overrideEnvironment method parses these variables and injects them into the XML configuration object app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php47-74

PDF and Layout Configuration

Configuration extends to specialized rendering subsystems:

Sources: