create-frontend-controller

Implement Magento 2 frontend controller actions with routing and DI.

15|1|Updated Oct 24, 2025
One-click install
npx skills add https://github.com/ProxiBlue/claude-skills --skill create-frontend-controller
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-frontend-controller
Source: https://github.com/ProxiBlue/claude-skills/tree/main/create-frontend-controller
Command: npx skills add https://github.com/ProxiBlue/claude-skills --skill create-frontend-controller

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers to implement a frontend controller action in Magento 2 for the storefront, covering routing, dependency injection, and response handling to ensure scalable, maintainable storefront logic.

Core Features & Use Cases

  • Routing configuration via etc/frontend/routes.xml to expose the controller under a frontend URL.
  • Dependency injection and avoidance of ObjectManager to create testable, robust controllers.
  • Support for multiple response types (JSON, page, redirects) using appropriate Magento result factories.
  • Encourages HTTP method discipline with HttpGetActionInterface and HttpPostActionInterface for storefront endpoints.

Quick Start

Create a minimal module with etc/frontend/routes.xml, implement a controller class under app/code/Vendor/ModuleName/Controller/Your/Action.php that implements HttpGetActionInterface (and optionally HttpPostActionInterface), wire up DI, and test the endpoint at /yourfrontname/controller/action.

Frequently Asked Questions about create-frontend-controller

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a frontend controller in Magento 2?

To create a Magento 2 frontend controller, configure etc/frontend/routes.xml, implement a controller class implementing HttpGetActionInterface, wire up dependency injection, and handle HTTP responses using Magento result factories.

How do I configure routing for a Magento 2 storefront endpoint?

Magento 2 storefront routing requires configuring the etc/frontend/routes.xml file in your module to expose the controller under a frontend URL and map your frontname to the controller action.

Should I use ObjectManager or dependency injection in Magento 2 controllers?

You should use dependency injection instead of ObjectManager in Magento 2 controllers to ensure your storefront logic remains testable, robust, and maintainable.

How do I return JSON or redirect responses from a Magento 2 frontend controller?

Magento 2 frontend controllers support multiple response types including JSON, pages, and redirects by utilizing the appropriate Magento result factories within your controller action class.

Do I need HttpGetActionInterface and HttpPostActionInterface for storefront endpoints?

Implementing HttpGetActionInterface and HttpPostActionInterface enforces HTTP method discipline for Magento 2 storefront endpoints, ensuring your frontend controller actions handle GET and POST requests correctly.

What prerequisites do I need to build a Magento 2 storefront controller?

Building a Magento 2 storefront controller requires a pre-existing Magento 2 module setup where you can define routes.xml and implement controller classes adhering to HTTP interface conventions.