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.