create-backend-controller_skill

This skill helps you generate Magento 2 admin backend controller actions with ACL, routing, and UI integration for admin pages and AJAX endpoints.

7

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill proxiblue/claude-skills --skill create-backend-controller

  • SKILL.md23.6 KB

Overview

This skill creates a Magento 2 backend (adminhtml) controller action with correct ACL, routing, authorization checks, and admin UI integration. It produces controller classes suited for grid pages, AJAX endpoints, form handlers, mass actions, and other admin operations. The output follows Magento best practices like strict types, HTTP method interfaces, and ADMIN_RESOURCE usage.

How this skill works

The skill generates controller classes that extend Magento\Backend\App\Action and implement the appropriate HttpGet/HttpPost interfaces. It wires result factories (PageFactory, JsonFactory, ResultRedirect) and uses defined ACL resource IDs so Magento automatically enforces authorization. It also shows required supporting configuration: acl.xml for resources, routes.xml for admin routing, and menu entries to surface pages in the admin UI.

When to use it

  • Building custom admin pages or grid controller actions
  • Adding AJAX endpoints for admin UI components or select-searchs
  • Implementing POST form handlers with form-key and redirect handling
  • Creating mass actions for admin grids (delete, update, export)
  • Any admin operation that must enforce permission checks and integrate with admin menu/navigation

Best practices

  • Always declare declare(strict_types=1) and type-hint properties/returns
  • Extend \Magento\Backend\App\Action and set const ADMIN_RESOURCE to an ACL id
  • Implement HttpGetActionInterface and/or HttpPostActionInterface to match allowed HTTP methods
  • Use PageFactory for HTML pages, JsonFactory for AJAX, and ResultRedirect for POST redirects
  • Define ACL resources in etc/acl.xml and admin routes in etc/adminhtml/routes.xml to ensure proper authorization and URL mapping

Example use cases

  • Admin grid listing: controller returns a Page, sets active menu and title
  • AJAX search endpoint: controller returns Json with options and pagination info
  • Form save action: validate POST, use repository/factory, add messages and redirect
  • Mass delete: filter selected collection, call repository deletes, and add success/error messages
  • Admin menu link: route maps to controller, visible when user has the configured ACL permission

FAQ

Controllers define const ADMIN_RESOURCE and inherit _isAllowed() from the backend Action base class; Magento checks the current admin user's ACL against that resource automatically.

Which result type should I use for different endpoints?

Use PageFactory for full admin pages, JsonFactory for AJAX or API-like responses, and ResultRedirect for POST handlers that need to redirect after processing.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational