Want to extend your store’s backend with custom features? Learning how to create a Magento 2 admin module is a great way to add tools and workflows tailored to your business. With a few configuration files and some PHP code, you can build a module that appears in the admin panel and handles tasks your store needs.
In this guide, we’ll walk through the essentials of Magento 2 create admin module development, from setting up the module structure to adding an admin menu and page. Whether you’re new to Magento development or ready to expand your skills, you’ll find a clear starting point for building a useful, maintainable admin experience.
Plan Your Magento 2 Create Admin Module and Set Up Its Structure
Before adding menus or building an admin page, give your code a clear home and a unique identity. A tidy foundation makes the next steps easier to test and helps prevent conflicts with other extensions.
Start by choosing a vendor name and module name that are unique to your project. The example below uses Acme as the vendor and CatalogTools as the module; replace both with names that fit your store.
Create the module directory, registration.php, and module.xml
Magento discovers modules in specific locations, so the directory and namespace must match. For a custom module, create the following structure under your Magento installation’s app/code directory:
app/code/Acme/CatalogTools/registration.phpapp/code/Acme/CatalogTools/etc/module.xml
In registration.php, register the module with Magento’s component registrar:
<?php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'AcmeCatalogTools', DIR);
Next, declare the same name in etc/module.xml. Keeping these identifiers consistent is essential—a mismatch can stop Magento from recognizing the component.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="AcmeCatalogTools" setupversion="1.0.0"/>
</config>
Once the files are in place, ask Magento to detect and enable the component before building on it. Run these commands from the Magento project root, where the bin/magento executable is available.
Check the module status and enable it with Magento CLI
First, check whether Magento can see the new module:
php bin/magento module:status AcmeCatalogTools
If it appears as disabled, enable it and apply the configuration changes:
php bin/magento module:enable AcmeCatalogTools
php bin/magento setup:upgrade
The setup:upgrade command synchronizes the module’s declared setup with the application. Then verify the result with php bin/magento module:status AcmeCatalogTools. If the module is not found, recheck the directory, file names, and exact spelling of AcmeCatalogTools; also confirm that your command-line user can read the files. With the module enabled, you’re ready to add its admin-specific configuration.
Configure the Admin Route, Menu, and Permissions
Your module is enabled, but administrators still need a safe, predictable way to reach its features. The route, menu item, and access-control rules work together: one directs requests, another provides navigation, and the third determines who is allowed in.
Start by connecting a URL to a controller action. Once that path works, you can expose it in the admin menu and restrict it to an appropriate permission.
Add admin routing and a controller action
Create etc/adminhtml/routes.xml to register a route with Magento’s admin router. The frontName becomes part of the module’s admin URL; Magento’s configured admin URL prefix comes before it.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="acmecatalogtools" frontName="catalogtools">
<module name="AcmeCatalogTools"/>
</route>
</router>
</config>Then add Controller/Adminhtml/Index/Index.php. This basic action renders an admin page, while ADMINRESOURCE ties the request to an ACL permission you’ll define next.
<?php
namespace AcmeCatalogToolsControllerAdminhtmlIndex;
use MagentoBackendAppAction;
use MagentoFrameworkViewResultPageFactory;
class Index extends Action
{
public const ADMINRESOURCE = 'AcmeCatalogTools::manage';
public function construct(
ActionContext $context,
private PageFactory $resultPageFactory
) {
parent::construct($context);
}
public function execute()
{
return $this->resultPageFactory->create();
}
}A working route is only useful if staff can find it—and access is limited to the right roles. Add a menu declaration and a matching ACL resource so navigation and authorization stay aligned.
In etc/adminhtml/menu.xml, point the menu item to the controller action and use the same resource identifier as the controller. The example places the entry under Magento’s Content menu; choose a different parent if that better fits your admin workflow.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:MagentoBackend:etc/menu.xsd">
<menu>
<add id="AcmeCatalogTools::manage"
title="Catalog Tools"
module="AcmeCatalogTools"
parent="MagentoBackend::content"
action="acmecatalogtools/index/index"
resource="AcmeCatalogTools::manage"/>
</menu>
</config>Finally, declare that permission in etc/acl.xml, nested beneath Magento’s admin resource:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="MagentoBackend::admin">
<resource id="AcmeCatalogTools::manage"
title="Manage Catalog Tools"
sortOrder="10"/>
</resource>
</resources>
</acl>
</config>After saving the files, clear the configuration cache with php bin/magento cache:clean config. Then assign the new permission to the appropriate admin role and test the page while signed in as a user with that role. This completes the key access path for your Magento 2 create admin module.
Build and Test Your Admin Page
Your route and permissions now provide the doorway; the next step is to give that doorway useful content. A small layout, block, and template are enough to confirm the page is rendering before you add more complex admin features.
Magento’s layout system connects the controller’s page result to the content shown in the browser. In this subsection, you’ll add a layout handle for your route, then use a block to pass data into a template.
Create the layout, block, and template files
Create view/adminhtml/layout/catalogtoolsindexindex.xml. The filename follows the route’s frontName, controller, and action, so it must match catalogtools/index/index. Add a block to the page’s content area:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/pageconfiguration.xsd">
<body>
<referenceContainer name="content">
<block class="AcmeCatalogToolsBlockAdminhtmlIndex"
name="acme.catalogtools.index"
template="AcmeCatalogTools::index.phtml"/>
</referenceContainer>
</body>
</page>Next, create Block/Adminhtml/Index.php and view/adminhtml/templates/index.phtml. The block can extend MagentoBackendBlockTemplate; the template can then show a simple heading, such as <h1><?= $block->escapeHtml(('Catalog Tools')) ?></h1>. Use escapeHtml() for displayed values, especially if they come from users or stored data. This keeps presentation separate from controller logic and gives your layout handle a clear, testable output.
Once the files are in place, test the full path from navigation to rendered content. A quick check can reveal whether the issue lies in routing, permissions, or the view layer.
Verify the Magento 2 create admin module setup and troubleshoot common issues
Sign in with an admin role that has the module’s ACL permission, open Content > Catalog Tools, and confirm that the heading appears. If you changed layout or template files, clear the relevant cache with php bin/magento cache:clean layout blockhtml; in developer workflows, refresh the page after cleaning.
If the page fails or appears blank, check these common causes:
- 404 or access denied: confirm the route URL and that the signed-in role has
AcmeCatalogTools::manage. - Missing content: verify the layout filename, block class namespace, and template path, including letter case.
- Class or XML errors: inspect Magento’s logs under
var/logand validate the PHP namespace and XML structure.
After resolving an error, reload the page and confirm both the menu link and direct route work. That final check helps ensure your Magento 2 create admin module is usable for the intended staff roles.
Turn Your Magento Admin Module Into a Tool Your Team Can Trust
Creating a Magento 2 admin module starts with a clear structure, then connects a secure route and menu to a useful page. With those foundations in place, you can build custom backend tools that fit your store’s workflows while keeping access limited to the right roles.
As you expand your module, keep its configuration consistent, follow Magento’s conventions, and test both permissions and page output. A small, well-organized starting point makes future features easier to maintain and troubleshoot. Now you’re ready to shape your Magento 2 create admin module around the needs of your team—and make everyday store management a little smoother.