Sunday, April 19, 2026
Magento

Module Scaffolding Tool

Scaffold the file structure and boilerplate for a new Magento 2 module.

Configuration
Generated Module Files
// Configure options on the left to generate module scaffolding

How to Use the Magento 2 Module Scaffolding Generator

The Module Scaffolding Generator produces the complete boilerplate for a new Magento 2 module in one click. Enter your vendor and module names, choose which optional files to include, and get all the files — with correct paths and content — ready to copy into your codebase.

Every Magento 2 module requires at minimum a registration.php file and an etc/module.xml. Beyond that, the correct structure depends on what the module does: frontend routes require a routes.xml, custom pages require a controller and layout XML, and data operations require model classes. Getting the namespace, module name, and file paths exactly right from the start avoids hard-to-trace autoloading and DI compilation errors.

Key Files Explained

  • registration.php — Registers the module with the Magento autoloader and component registry. Must be present in the module root.
  • etc/module.xml — Declares the module name and setup version for Magento's module management system.
  • composer.json — Required when distributing the module via Composer. Defines the package name, type (magento2-module), and autoload PSR-4 mapping.
  • etc/frontend/routes.xml — Registers the frontend URL route. The front name maps URLs like /routename/* to the module's controllers.
  • Controller/Index/Index.php — The default controller action that handles /routename/index/index requests. Extends Action and uses the result page factory.
  • Block/Main.php — A view block that provides data to PHTML templates. Extends Template and is referenced from layout XML.
  • Model/Main.php — A model class for business logic. Extend AbstractModel when backed by a database resource model.
  • view/frontend/layout/*.xml — The layout handle XML that binds a block to the controller's response page.

After Generating

Once you copy the files into app/code/{Vendor}/{Module}/, run bin/magento module:enable {Vendor}_{Module} followed by bin/magento setup:upgrade and bin/magento cache:clean to activate and register the module.