VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/3-core-architecture

⇱ Core Architecture | MahoCommerce/maho | DeepWiki


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

Core Architecture

Purpose and Scope

This document provides a high-level deep dive into Maho's foundational architecture patterns and systems. It explains the structural relationship between the central hub, the configuration tree, and the modular extensibility of the platform.

Detailed technical documentation for each subsystem can be found in the following child pages:

The Mage Static Hub

The Mage class app/Mage.php18-121 is the central orchestration point. It is a final class that provides static access to the application instance, configuration, and factory methods. It serves as the primary entry point for almost all internal logic.

Core Registry and Properties

The class maintains several critical static properties that represent the state of the running application:

PropertyTypePurpose
$_appMage_Core_Model_AppThe application model managing the request lifecycle app/Mage.php71
$_configMage_Core_Model_ConfigThe merged XML configuration tree app/Mage.php78
$_events\Maho\Event\CollectionCollection of registered observers for event dispatching app/Mage.php85
$_registryarrayA global key-value store for shared objects app/Mage.php57

Mage Static Hub Architecture


Sources: app/Mage.php18-137

Factory Pattern and Class Resolution

Maho uses string aliases (e.g., tax/observer) to instantiate classes. This abstraction allows the system to support Class Rewrites, where a module can override a core class by changing the configuration without touching the original core file.

Object Instantiation Workflow

When Mage::getModel('tax/observer') is called, the following resolution occurs:

  1. Prefix Resolution: The system identifies tax as the group and observer as the class entity.
  2. Configuration Lookup: It checks global/models/tax/class in the merged XML to find the base class name (e.g., Mage_Tax_Model) app/code/core/Mage/Tax/etc/config.xml19-23
  3. Rewrite Check: It checks for any <rewrite> nodes under that group in the configuration app/code/core/Mage/Core/Model/Config.php115-128
  4. Instantiation: The final class name (e.g., Mage_Tax_Model_Observer) is generated, cached in $_classNameCache app/code/core/Mage/Core/Model/Config.php118 and instantiated.

Code Entity Mapping: Factory to Class


Sources: app/code/core/Mage/Core/Model/Config.php114-128 app/code/core/Mage/Tax/etc/config.xml19-23

Configuration System

The Mage_Core_Model_Config class app/code/core/Mage/Core/Model/Config.php13-73 aggregates XML files from the core, community, and local pools into a single searchable tree.

Merging Hierarchy

  1. Base Configuration: app/etc/*.xml (including local.xml for DB credentials).
  2. Module Configuration: etc/config.xml from every active module defined in MAGE_MODULES app/code/core/Mage/Core/Model/Config.php15-73
  3. Database Overrides: Values stored in the core_config_data table, accessed via the resource model app/code/core/Mage/Core/Model/Config.php236-242

Cache Sections

To improve performance, the configuration is split into sections that can be cached independently app/code/core/Mage/Core/Model/Config.php91-97:

  • adminhtml, crontab, install, stores, websites.

Sources: app/code/core/Mage/Core/Model/Config.php13-98

Event-Driven Extensibility

Maho provides a robust event system via Mage::dispatchEvent(). In addition to traditional XML-based observer registration, Maho introduces PHP Attributes for observer registration lib/Maho/Config/Observer.php26-28

Observer Types

Event Flow Diagram


Sources: app/Mage.php85 app/code/core/Mage/CatalogInventory/Model/Observer.php44-45 lib/Maho/Config/Observer.php27

Multi-Store Architecture

The platform is designed for multi-tenancy using a hierarchical structure of Websites, Store Groups, and Store Views.

Configuration values can be set at any level of this hierarchy, with the most specific (Store View) overriding the more general (Website or Default) app/code/core/Mage/Core/Model/Config.php95-96 The application initializes the current store during bootstrap app/code/core/Mage/Core/Model/App.php268

Sources: app/code/core/Mage/Core/Model/Config.php91-97 app/code/core/Mage/Core/Model/App.php79-160 app/code/core/Mage/Core/Model/App.php268

Summary of Core Classes

Class NameFile PathPrimary Responsibility
Mageapp/Mage.phpGlobal static hub and factory.
Mage_Core_Model_Configapp/code/core/Mage/Core/Model/Config.phpLoads, merges, and caches XML configuration.
Mage_Core_Model_Appapp/code/core/Mage/Core/Model/App.phpManages application state, stores, and request lifecycle app/code/core/Mage/Core/Model/App.php248-271

For a deep dive into how these systems initialize, proceed to Application Bootstrap.