Repository navigation
Code Generation Overview
4 tools for scaffolding Magento modules, models, controllers, and REST API endpoints with proper structure and configuration.
Scaffold a complete new module.
| Parameter | Type | Default | Description |
|---|---|---|---|
vendor |
string | required | Vendor name (e.g., Inchoo) |
module |
string | required | Module name (e.g., CustomPricing) |
version |
string | 1.0.0 |
Module version |
dry_run |
bool | false | Preview without writing |
force |
bool | false | Overwrite existing files |
Generated files:
registration.phpetc/module.xmlcomposer.json
Generate model, resource model, and collection with database schema.
| Parameter | Type | Default | Description |
|---|---|---|---|
vendor |
string | required | Vendor name |
module |
string | required | Module name |
entity |
string | required | Entity name (e.g., Subscription) |
table |
string | required | Database table name |
fields |
string | "" |
Comma-separated field definitions |
dry_run |
bool | false | Preview without writing |
force |
bool | false | Overwrite existing files |
Generated files:
Model/<Entity>.phpModel/ResourceModel/<Entity>.phpModel/ResourceModel/<Entity>/Collection.phpetc/db_schema.xml
Generate controller with route, layout, and template.
| Parameter | Type | Default | Description |
|---|---|---|---|
vendor |
string | required | Vendor name |
module |
string | required | Module name |
action |
string | index |
Action name |
area |
string | frontend |
frontend or adminhtml
|
route |
string | custom |
Route front name |
dry_run |
bool | false | Preview without writing |
force |
bool | false | Overwrite existing files |
Generated files:
-
Controller/<Action>.php(orController/Adminhtml/<Action>.php) etc/<area>/routes.xmlview/<area>/layout/<route>_index_<action>.xmlview/<area>/templates/<action>.phtml
Generate REST API endpoint with interface and webapi.xml configuration.
| Parameter | Type | Default | Description |
|---|---|---|---|
vendor |
string | required | Vendor name |
module |
string | required | Module name |
resource |
string | required | Resource name (e.g., Subscription) |
method |
string | GET |
HTTP method |
path |
string | "" |
Custom API path |
dry_run |
bool | false | Preview without writing |
force |
bool | false | Overwrite existing files |
Generated files:
Api/<Resource>Interface.php-
Model/<Resource>.php(implementation) etc/webapi.xml-
etc/di.xml(preference mapping)
All generators support dry_run=true to preview files without writing:
generate-module vendor="Inchoo" module="CustomPricing" dry_run=true
Output includes file paths, content preview, and new/exists annotations.
Existing files cause a conflict error by default. Use force=true to overwrite:
generate-model vendor="Inchoo" module="CustomPricing" entity="Rule" table="inchoo_pricing_rule" force=true
All code generation tools are blocked in production mode. This cannot be overridden.
Getting Started
Architecture
Tools Reference
- Overview (84 Tools)
- Introspection
- Catalog
- Orders
- Customers
- Database
- Logs & Diagnostics
- GraphQL
- Development
Configuration
Guidelines & Skills
Code Generation
Diagnostics
Security