Create Your First Front Controller

In magento we have two types of controllers: front controllers and admin controllers. In this guide we will create very simple front controller with hello world method, than we call it with URL.

You need to create module first, if you don’t know how, follow this tutorial.

In your module folder open [module folder]/etc/config.xml and register your new route like this:

          <[company name]_[module name]> 
                  <module>[Company Name]_[module name]</module>                   
               <frontName>[first_part_of_url]</frontName> <!-- This will be first part of URL --> 
          </[company name]_[module name]> 

Create controller file itself

We will call our controller IndexController.php and we will create it inside our module controllers forlder.

so create file like this [module folder]/controllers/IndexController.php and write following code:

// Watch out, [Company name] and [Module name] has to by capitalized
class [Company name]_[Module name]_IndexController extends Mage_Core_Controller_Front_Action {
    public function helloAction () {
        echo 'Hello World.';

    public function indexAction () {
        echo 'This is index action.';


Don’t forget to flush cache and then you should be able to call URL like this[module name]/index/hello

you will see Hello world

and when you call this[module name]/

you will see This is index action.

If you want to see the store, you need to render shop files. Just add these two lines of code into your controller’s method.

$this->loadLayout(); // wich elements to get?
$this->renderLayout(); // render them



Lukas Stranovsky
I am the guy who made this. Sorry for typos.