![]() |
VOOZH | about |
The Module System is Maho's architectural pattern for organizing functionality into self-contained, reusable components. This document covers module structure, declaration, dependency resolution, and integration with the configuration system.
Maho maintains compatibility with the legacy Magento 1 module structure while modernizing the platform through PHP 8.3+ standards and streamlined core logic app/code/core/Mage/Core/Model/Config.php7-11
Modules in Maho are self-contained packages that extend the platform's functionality. Each module encapsulates related business logic, including models, blocks, controllers, helpers, and configuration. The module system provides:
Namespace_Module naming convention (e.g., Mage_Core app/code/core/Mage/Core/Model/Config.php16 Maho_AdminActivityLog app/code/core/Maho/AdminActivityLog/Model/Observer.php12).config.xml into the global configuration tree app/code/core/Mage/Core/Model/Config.php274-280Each module follows a standardized directory structure within its code pool location:
Key Configuration Files:
| File | Purpose | Required |
|---|---|---|
config.xml | Defines models, blocks, helpers, events, and routes. | Yes |
system.xml | Defines configuration fields for the Admin System > Configuration section. | No |
Sources: app/code/core/Mage/Core/Model/Config.php274-280 app/code/core/Mage/Core/Model/Config.php89-95
Modules are activated via XML declaration files located in app/etc/modules/. These files define the module's presence to the configuration object during initialization.
Maho maintains an internal hardcoded list of core modules to ensure consistent loading order for base components and critical platform functionality app/code/core/Mage/Core/Model/Config.php15-71
Modern Maho modules are managed via Composer. The Maho utility class provides methods to interact with installed packages:
Maho::getInstalledPackages(): Returns an array of Maho packages installed via Composer lib/Maho.php32-35Maho::findFile(): Resolves absolute paths for files within installed packages, respecting overrides lib/Maho.php134-146Title: Module Configuration Initialization Flow
Sources: app/Mage.php126-137 app/code/core/Mage/Core/Model/Config.php272-280 lib/Maho.php32-35
Maho uses code pools and the Composer autoloader to organize source code and allow for overrides.
| Pool | Location | Usage |
|---|---|---|
| core | app/code/core/ | Reserved for Maho core modules (Mage_* and Maho_*). |
| local | app/code/local/ | Used for site-specific customizations and legacy overrides. |
| community | app/code/community/ | Legacy pool for third-party extensions. |
Maho integrates deeply with the Composer ClassLoader lib/Maho.php163-169 During development, the system can update the autoloader dynamically to reflect new files or class map changes lib/Maho.php174-195
Sources: app/Mage.php253-256 lib/Maho.php163-169 lib/Maho.php174-195
Maho uses a factory pattern to instantiate module classes based on configuration aliases defined in config.xml.
Title: Factory Pattern Class Resolution
Maho is transitioning from legacy Varien_ namespaces to modern Maho\ namespaces. This is reflected in the Composer autoload configuration composer.json110-115
Sources: app/code/core/Mage/Core/etc/config.xml20-24 composer.json110-115
Maho introduces a modernized way to declare module functionality using PHP 8.3 attributes. This reduces reliance on XML and allows for a more developer-friendly experience.
To maintain high performance, attributes are compiled into a PHP file at vendor/composer/maho_attributes.php lib/Maho.php51-58 This file is generated via the Maho::recompilePhpAttributes() method, which triggers the AttributeCompiler lib/Maho.php69-102
Observers can be registered directly on class methods using the #[Maho\Config\Observer] attribute.
Mage_CatalogInventory_Model_Observer::addInventoryData observes catalog_product_load_after app/code/core/Mage/CatalogInventory_Model_Observer.php44-45Maho_AdminActivityLog_Model_Observer::logAdminLogin observes admin_user_authenticate_after app/code/core/Maho/AdminActivityLog/Model/Observer.php48-49Cron jobs are also defined via attributes (e.g., #[Maho\Config\CronJob]), moving away from the <crontab> section in config.xml.
Sources: lib/Maho.php51-58 lib/Maho.php69-102 app/code/core/Mage/CatalogInventory/Model/Observer.php44-46
Modules can be enabled or disabled through two primary mechanisms:
<active>false</active> in app/etc/modules/Namespace_Module.xml.Module configuration is heavily cached. The CONFIG cache type stores the merged config.xml and local.xml trees app/code/core/Mage/Core/etc/config.xml116-120 When modules are added or updated, this cache must be refreshed via the Admin or CLI.
Sources: app/code/core/Mage/Core/etc/system.xml86-94 app/code/core/Mage/Core/etc/config.xml116-120
Title: Configuration Node Hierarchy
Refresh this wiki