Magento – Controllers

A Magento controller is an action that directs the flow of the site from one location to another, based on the URL routing. Firstly it is worth giving some consideration to the typical, but somewhat humble URL. An interpretation from the perspective Magento follows:

The URL shown above can be separated into the following components: – root domain

/catalog – This is the {module} that the controller is found in

/category – This is the {controller} name to be used

/view – This is the name of the {action} to be called

/id/1 – These are PARAMETERS passed to the action through GET request variables.

The process of reducing the URL in this fashion is also referred to as ROUTING.  If Magento is unable to find the CONTROLLER or ACTION, it will pass responsibility through to a secondary set of instructions for the admin application.  If nothing exists there, then it will finally attempt to fall back to a special predefined controller called Mage_Cms_IndexController.

Magento controllers are designed for simplicity and their main purpose is to direct flow to other elements to handle the processing.

This is somewhat abstract, but it explains the basics behind what a controller does and some information on why it does what it does.

To understand it in greater depth from a development perspective it would be worth spending a little time working through the basic articles on controllers.