Module Development
Modules are the primary way to extend Thelia. Use them to add features, integrate third-party services, and customize behavior, up to building a complete e-commerce solution.
One module per project
Create a single module for all your project-specific logic. Only split into separate modules if you plan to share them with the community or need distinct functionality boundaries.
Module Locations
Thelia 3 has two locations for modules:
Vendor Modules (Official)
Official and community modules installed via Composer:
vendor/thelia/modules/
├── CustomerFamily/
├── Carousel/
├── HookAdminHome/
└── ...
Local Modules (Custom)
Your project-specific modules:
local/modules/
├── MyProject/
└── ...
Priority: Modules in local/modules/ take precedence over vendor/thelia/modules/, allowing you to override vendor modules when needed.
Creating a Module
Use the module generator command:
php Thelia module:generate MyProject
This creates the basic structure in local/modules/MyProject/.
Module Capabilities
Modules can:
| Capability | Description |
|---|---|
| API Resources | Expose data via API Platform endpoints |
| API Addons | Enrich existing resources with additional data |
| LiveComponents | Create interactive front-office components |
| Controllers | Handle HTTP requests (front and admin) |
| Event Listeners | React to system events |
| Loops | BaseLoop is the extension point of the legacy loop data layer, called by {loop} in Smarty templates and by the loop() Twig function; for new code, prefer API resources |
| Hooks | Inject content into back-office templates |
| Forms | Create validated forms |
| Commands | Add CLI commands |
| Database Tables | Define custom Propel schemas |
Module Structure
local/modules/MyProject/
├── MyProject.php # Main module class (required)
├── composer.json # For distribution
├── Config/
│ ├── module.xml # Module metadata (required, XSD module-2_2.xsd)
│ ├── config.xml # Legacy XML config (stub still required as a file; content optional)
│ ├── routing.xml # Legacy routes (optional, prefer #[Route] attributes)
│ └── schema.xml # Database schema (only if you define tables)
├── Api/
│ ├── Resource/ # API Platform resources
│ └── Addon/ # Resource addons
├── Controller/
│ ├── Front/ # Front-office controllers
│ └── Admin/ # Back-office controllers
├── EventListeners/ # Event subscribers