Create a Magento Controller

🛒 B-Online Store

Premium Magento 2 Extensions & Services

Enhance your e-commerce store with high-quality extensions and expert Magento development services. Trusted by thousands of merchants worldwide!

💬 WhatsApp Button ⚡ Flash Sale 🏷️ Product Labels 🌐 Translation Suite
🔥 UP TO 71% OFF Limited Time!
⭐ Thousands of Merchants 🛡️ Quality Guaranteed ⚡ Instant Download
YouTube player

How to Create a Magento Controller

As we discuss in the previous lesson the Controller consist of two parts controllerName and actionName

We will create new controller under Kickstart folder

Controller/Index/Index.php

and we will use predefined template to create our controller

For now, we will just use the die() function to output some text to make sure things are working.

<?php

declare(strict_types=1);

namespace Itcforu\Kickstart\Controller\Index;

use Magento\Framework\App\Action\HttpGetActionInterface;

class Index implements HttpGetActionInterface
{
    public function execute()
    {
        die('kickstart!');
    }
}