What is the difference between Magneto1 and Magento2 controller in term of the development ?

2 Answers 2


To add on what Pankaj Pareek said...
In Magento 2, controllers don't have a special treatment like it did in Magento 1.
In Magento 2, controllers can be found in the Controller folder of the module and they are loaded following the same autoloader pattern. Class name must match folder path name and they don't need the Controller suffix.
M1: file: Mage/Catalog/controllers/ProductController, class Mage_Catalog_ProductController. Notice that controllers is lowercase and it is not included in the class name.
M2: file Magento/Catalog/Controller/Product/View, class Magento\Catalog\Controller\Product\View.
The upside is that if you want to extend a controller class, you don't need to add require_once 'Controller/File/Path/Here.php'. The autoloader does its job.

In Magento 1, controller actions don't really return anything. They can just render the layout or redirect, or forward to another action.
In Magento 2, you can still do the same as in M1, but it's highly discouraged. Instead your actions should return and instance of Magento\Framework\Controller\ResultInterface


Its Completely Changed.

In Magento 1 Controller is one php file that contain all the actions functions.

In Magento 2 Controller work like as folder that group all the Actions PHP files and each Actions PHP file have one execute function as entrypoint.

Check below Contacts Module Index Controller In Magento 1 and Magento 2 for more difference:

Magento 1


Magento 2


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.