I am new in learning Magento 2 and I installed a module Ves Brand , now I want to create a page that show all brands I need to create a controller


I would recommend using Alan Storm's code generation tool Pestle. It will help you create all the elements of a full module, and helps to reduce the typo hell the new users can get into. For what you are trying to do, you can get deep background with his tutorial series. But in the short term here is what you need to do to get a controller and a view set up.

After installing the pestle.phar file you can get on the github page, take a look at all the commands with:

php pestle.phar

To start we want to generate a module with:

php pestle.phar magento2:generate:module

This will walk you through the needed namespaces ect. you can change these up to your needs. Hitting enter will give you the default value in the ():

Vendor Namespace? (Pulsestorm)] Tester
Module Name? (Testbed)] Brands
Version? (0.0.1)] 
Created: /Applications/MAMP/htdocs/magento222.test/app/code/Tester/Brands/etc/module.xml
Created: /Applications/MAMP/htdocs/magento222.test/app/code/Tester/Brands/registration.php

The you want to create your controller with:

php pestle.phar magento2:generate:route

I used these values:

Which Module? (Pulsestorm_HelloWorld)] Tester_Brands
Which Area (frontend, adminhtml)? (frontend)] 
Frontname/Route ID? (pulsestorm_helloworld)] tester_brands
Controller name? (Index)] 
Action name? (Index)] 

And then we create the view for our route with:

php pestle.phar magento2:generate:view

Which Module? (Pulsestorm_HelloGenerate)] Tester_Brands
Which Area? (frontend)] 
Which Handle? (tester_brands_index_index)] 
Block Name? (Main)] 
Template File? (content.phtml)] 
Layout (ignored for adminhtml) ? (1column)] 
Creating /Applications/MAMP/htdocs/magento222.test/app/code/Tester/Brands/view/frontend/templates/content.phtml
Creating: Tester\Brands\Block\Main
Creating: /Applications/MAMP/htdocs/magento222.test/app/code/Tester/Brands/view/frontend/layout/tester_brands_index_index.xml

You should now be able to run php bin/magento setup:upgrade and then clear your cache and hit the new view with this url:


For the question about getting the brands to show up on this new view, i'll answer that in the other question you have or here:

How to create a page that show all brands magento 2

  • No need bash tool to create Magento Module. – HoangHieu Sep 10 '18 at 7:12
  • there is no need, but this is an option that people can use to build modules without the kind of typo errors that can stall a build. I make that point in my answer. If you have a better suggestion or solution, please write an answer to the question. – circlesix Sep 11 '18 at 17:49
  • Use auto tool if only you know magento structrer and can control problem when working in module, if not, you can suggest orther way without tool. – HoangHieu Sep 12 '18 at 1:39
  • or you can contribute an answer. The idea here is the best answer rises to the top, not the the best comment. – circlesix Sep 12 '18 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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