Welcome to Magento 2 – Developer help site. This is the first post on the blog and would like to share information for Magento 2 beginners who already experienced and worked with Magento 1x.

As per your previous experience while learning Magento 1x by creating your first module Hello world! you know modules were spread all over the place: code, templates, JS and other resources in any of several places. Code pools (app/code/core, community, local) are also no more. Everything related to a module is now contained within that module’s directory: app/code/{vendor}/{module}/.

The folder structure within a module is mostly arbitrary now, though there are still some conventions (Block, Controller, Helper, Model). There are some exceptions:

  • Config still goes into etc/.
  • DB setup scripts go into special files in Setup/.
  • Template files, layout XML, CSS, JS, etc. go into respective folders within view/.

Before start writing the code, I would like to share files path which is covered by MVC pattern to create a module.

“Infologic” is the Namespace, We can say “Company Name”.
“Helloworld” is the Module Name.

Now this is the time to start our first module Hello World!

1. \app\code\Infologic\Helloworld\etc\module.xml

2. \app\code\Infologic\Helloworld\registration.php

3. \app\code\Infologic\Helloworld\etc\frontend\routes.xml

4. \app\code\Infologic\Helloworld\Block\Helloworld.php

5. \app\code\Infologic\Helloworld\Model\Helloworld.php

6. \app\code\Infologic\Helloworld\view\frontend\layout\helloworld_index_index.xml

7. \app\code\Infologic\Helloworld\view\frontend\templates\helloworld.phtml

8. \app\code\Infologic\Helloworld\Controller\Index\Index.php

8. Simple module creation is complete. If you have any issues or views, please feel free to write us.

Thanks for reading this post. Happy coding!

Leave a Reply

Notify of