VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/12-extension-development

⇱ Extension Development | MahoCommerce/maho | DeepWiki


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

Extension Development

Purpose and Scope

This page provides a high-level guide to developing extensions (modules) for the Maho e-commerce platform. It covers the module system architecture, configuration mechanisms, and integration points that allow developers to extend and customize Maho functionality without modifying core code.

For specific extension development tasks:

For core architecture concepts referenced here, see Module System and Event System and Observers.


Module System Architecture

Maho's extension system is built on a modular architecture where functionality is organized into discrete modules. Each module is a self-contained package that can add or modify functionality through well-defined integration points.

Module Structure

A typical Maho module follows this directory structure:

app/code/{codePool}/{Namespace}/{Module}/
├── etc/
│ ├── config.xml # Core module configuration
│ ├── system.xml # Admin system configuration
│ └── adminhtml.xml # Admin menu and ACL
├── Model/ # Business logic classes
├── Block/ # View layer classes
├── Helper/ # Utility classes
├── controllers/ # HTTP request handlers
├── sql/ # Database setup/upgrade scripts
└── data/ # Data setup/upgrade scripts

Modules are declared in app/etc/modules/{Namespace}_{Module}.xml files, which control module activation and dependencies. The core configuration model Mage_Core_Model_Config manages the loading and merging of these definitions app/code/core/Mage/Core/Model/Config.php13-14

Sources:

Module Discovery and Loading

Maho identifies active modules through the configuration system. The application initializes the configuration model during bootstrap, which parses module XML files and builds the internal configuration tree.

Module Discovery Process


Sources:


Configuration System

Configuration Loading Hierarchy

Configuration is loaded in stages, with later stages able to override earlier ones. The Mage_Core_Model_Config class handles this merging process, ensuring that environment-specific settings in local.xml or the database take precedence over default module settings.

Configuration Merge Sequence
































StageSourcePurpose
Baseapp/etc/*.xmlCore system defaults app/code/core/Mage/Core/Model/Config.php279
Modulesetc/config.xmlModule-specific declarations (Models, Blocks, Helpers)
Localapp/etc/local.xmlInstallation-specific credentials app/code/core/Mage/Core/Model/Config.php192-194
Databasecore_config_dataStore-scope configuration managed via Admin UI app/code/core/Mage/Core/Model/Config.php236-242

Sources:


Factory Pattern and Class Resolution

Maho uses a factory pattern to instantiate objects, allowing modules to override core classes through configuration. This is primarily handled via the Mage class.

Modernization and Autoloading

Maho leverages Composer for class loading and package management. The Maho utility class provides methods to interact with the environment, such as getInstalledPackages() lib/Maho.php32-35 and findClassFile() lib/Maho.php208-211 Developers are encouraged to use the Maho\ namespace for new PSR-4 compliant code composer.json113

Factory Methods

The main factory methods in the Mage class are used to instantiate models and helpers based on class aliases defined in config.xml.

Factory Pattern Flow
































Factory MethodPurposeImplementation Pointer
Mage::getModel()Create new model instanceapp/Mage.php465-474
Mage::getSingleton()Get singleton modelapp/Mage.php491-500
Mage::getResourceModel()Create resource modelapp/Mage.php514-523
Mage::helper()Get helper singletonapp/Mage.php561-570

Sources:


Event System Integration

The event system provides non-invasive extension points. Modules can observe events without modifying core code. Maho supports both traditional XML-based observers and a modernized PHP Attribute-based observer system.

Event Observer Architecture


Modern observers use the #[Maho\Config\Observer] attribute. These attributes are compiled into a performance-optimized file vendor/composer/maho_attributes.php lib/Maho.php51-58 Developers can trigger a recompile using Maho::recompilePhpAttributes() lib/Maho.php69-70

Sources:


Command Discovery and CLI Extensions

Maho includes a modernized CLI based on Symfony Console. Custom modules can add CLI commands that are automatically discovered.

CLI Registration Pattern

Commands are typically integrated via Symfony's symfony/console package composer.json58 The maho script serves as the entry point for all administrative tasks, including cache management and indexer control.

CLI Command Discovery


Sources:


Child Pages

For detailed technical implementation, please refer to the following guides: