SlideShare a Scribd company logo
How to create a module in Magento 2.0
(Updated in August 2015)
2
1 THE STRUCTURE OF A SIMPLE MODULE
Magento 1 vs Magento 2
Some new folders in Magento 2
2
CREATE A SIMPLE MODULE IN MAGENTO 2
Step 1: Create configuration files
Step 2: Create controller, layout and template files
Step 3: Activate the module in the configuration file
OUTLINE
MAGENTO 2
Folders and files of a module are put in
only a package and located in app/code
folder
1. THE STRUCTURE OF A SIMPLE MODULE
MAGENTO 1
Folders and files of a module are located
in different folders: app/code/local,
app/code/community, app/design,
app/etc, app/locale, js, skin,…
Some new folders in Magento 2
i18n: store the .csv files for module
translator. Eg: en_US.csv, de_DE.csv
Setup: store the files which are used to
create tables or insert data to the
database.
View: This folder stores the layout,
template, image, CSS and Javascript
files which are used for your module.
Let’s create folders with the structure as
following:
Namespace: Tutorial
Module name: Example
Example link on Local host:
http://localhost/magento2/exam
ple/index/index/
2. CREATE A SIMPLE MODULE IN MAGENTO 2
Step 1: Create configuration files
1.1. Create file: app/code/Tutorial/Example/etc/module.xml
Purpose: Declare your module
Source Code:
(Go to our blog tutorial for full source code)
Step 1: Create configuration files
1.2 Create file:
app/code/Tutorial/Example/etc/frontend/routes.xml
Purpose: Declare the router of module for frontend
(Go to our blog tutorial for full source code)
Step 2: Create controller, layout and template files
2.1 Create the controller
file: app/code/Tutorial/Example/Controller/Index/Index.php
=> The souce code is found in our blog tutorial
Step 2: Create controller, layout and template files
2.2 Create the layout file:
app/code/Tutorial/Example/view/frontend/layout/example_inde
x_index.xml
(Go to our blog tutorial for full source code)
Step 2: Create controller, layout and template files
2.3 Create the template file:
app/code/Tutorial/Example/view/frontend/templates/index.phtml
(Go to our blog tutorial for full source code)
Step 3: Activate the module in the configuration file
3.1 Activate module by opening app/etc/config.php file then
add this line “'Tutorial_Example' => 1” into it:
(Go to our blog tutorial for full source code)
Step 3: Activate the module in the configuration file
3.2 Open the Command in Windows (or the Terminal in Linux
and MAC OS). Go to Magento root folder and run this
command line to install module:
binmagento setup:upgrade
(Go to our blog tutorial for full source code)
Step 3: Activate the module in the configuration file
3.3 Clear the Magento cache then access with
url http://localhost/magento2/example/index/index/
Following MageWorld Magento 2 Tutorial Series…

More Related Content

PDF
How to-create-a-simple-module-in-magento-2.0
DOCX
PPTX
Android Fundamental
PPTX
Top 11 most popular drupal 8 ready modules of 2017
PDF
[PBO] Pertemuan 12 - Pemrograman Android
PPT
How to Use the Media Center
DOC
памятка туристу в китай 1
PPS
215 - Erica Hopper-painter
How to-create-a-simple-module-in-magento-2.0
Android Fundamental
Top 11 most popular drupal 8 ready modules of 2017
[PBO] Pertemuan 12 - Pemrograman Android
How to Use the Media Center
памятка туристу в китай 1
215 - Erica Hopper-painter

Viewers also liked (18)

PDF
Presentatie taskforce social op Interact 2010 deel1
PDF
Comm final project
PDF
PPTX
Svadebnaya masterskaya
PPTX
Png还是jpg,这是个问题
PDF
Fundusze inwestycyjne
PPTX
Presentation1
PPS
237-Vineyards-comptine
PDF
Models by Percent Discount
PDF
2011 Toyota Corolla Plano
PDF
2011 Toyota Highlnder Plano
PPTX
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
PPTX
Social Media: Which to? How to? Why to?
PPSX
PDF
Blog her devries_surveyfinal, ec
PPTX
Central Banks Macro Adjustments
PDF
Communique -- May 2010
PDF
Rrb po-clerk-capsule-2015
Presentatie taskforce social op Interact 2010 deel1
Comm final project
Svadebnaya masterskaya
Png还是jpg,这是个问题
Fundusze inwestycyjne
Presentation1
237-Vineyards-comptine
Models by Percent Discount
2011 Toyota Corolla Plano
2011 Toyota Highlnder Plano
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
Social Media: Which to? How to? Why to?
Blog her devries_surveyfinal, ec
Central Banks Macro Adjustments
Communique -- May 2010
Rrb po-clerk-capsule-2015
Ad

Similar to How to create a simple module in Magento 2.0 (20)

PDF
Federico Soich - Upgrading Magento Version
PDF
M2ModuleDevelopmenteBook
PDF
How To Create Theme in Magento 2 - Part 1
PDF
How to create theme in Magento 2 - Part 2
PPT
Mageguru - magento custom module development
PPTX
Tips On Trick Odoo Add-On.pptx
PPTX
Madison PHP - Getting Started with Magento 2
PPT
12 Amazing Features of Magento 2
PDF
Struts2 tutorial
PDF
Struts2 tutorial
PDF
Struts2 tutorial
PPTX
Create Basic module in magento2| Tuitorial hello world Magento2
PPTX
Create basic hello world module in magento2
PDF
Architecture and Analytical Study of Magento
PDF
Convert Magento 1 Extensions to Magento 2
DOCX
fuelOrigin.docx
PPT
Introduction to Mangento
PPT
Mangento
PPTX
Tips On Trick Odoo Add-On.pptx
PPT
CICON2010: Adam Griffiths - CodeIgniter 2
Federico Soich - Upgrading Magento Version
M2ModuleDevelopmenteBook
How To Create Theme in Magento 2 - Part 1
How to create theme in Magento 2 - Part 2
Mageguru - magento custom module development
Tips On Trick Odoo Add-On.pptx
Madison PHP - Getting Started with Magento 2
12 Amazing Features of Magento 2
Struts2 tutorial
Struts2 tutorial
Struts2 tutorial
Create Basic module in magento2| Tuitorial hello world Magento2
Create basic hello world module in magento2
Architecture and Analytical Study of Magento
Convert Magento 1 Extensions to Magento 2
fuelOrigin.docx
Introduction to Mangento
Mangento
Tips On Trick Odoo Add-On.pptx
CICON2010: Adam Griffiths - CodeIgniter 2
Ad

Recently uploaded (20)

PDF
Time Tracking Features That Teams and Organizations Actually Need
PPTX
Custom Software Development Services.pptx.pptx
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
Patient Appointment Booking in Odoo with online payment
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Cybersecurity: Protecting the Digital World
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
Cost to Outsource Software Development in 2025
PPTX
assetexplorer- product-overview - presentation
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
Time Tracking Features That Teams and Organizations Actually Need
Custom Software Development Services.pptx.pptx
Autodesk AutoCAD Crack Free Download 2025
Patient Appointment Booking in Odoo with online payment
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
iTop VPN Crack Latest Version Full Key 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
chapter 5 systemdesign2008.pptx for cimputer science students
Complete Guide to Website Development in Malaysia for SMEs
Cybersecurity: Protecting the Digital World
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Topaz Photo AI Crack New Download (Latest 2025)
Cost to Outsource Software Development in 2025
assetexplorer- product-overview - presentation
Why Generative AI is the Future of Content, Code & Creativity?
wealthsignaloriginal-com-DS-text-... (1).pdf
Digital Systems & Binary Numbers (comprehensive )

How to create a simple module in Magento 2.0

  • 1. How to create a module in Magento 2.0 (Updated in August 2015) 2
  • 2. 1 THE STRUCTURE OF A SIMPLE MODULE Magento 1 vs Magento 2 Some new folders in Magento 2 2 CREATE A SIMPLE MODULE IN MAGENTO 2 Step 1: Create configuration files Step 2: Create controller, layout and template files Step 3: Activate the module in the configuration file OUTLINE
  • 3. MAGENTO 2 Folders and files of a module are put in only a package and located in app/code folder 1. THE STRUCTURE OF A SIMPLE MODULE MAGENTO 1 Folders and files of a module are located in different folders: app/code/local, app/code/community, app/design, app/etc, app/locale, js, skin,…
  • 4. Some new folders in Magento 2 i18n: store the .csv files for module translator. Eg: en_US.csv, de_DE.csv Setup: store the files which are used to create tables or insert data to the database. View: This folder stores the layout, template, image, CSS and Javascript files which are used for your module.
  • 5. Let’s create folders with the structure as following: Namespace: Tutorial Module name: Example Example link on Local host: http://localhost/magento2/exam ple/index/index/ 2. CREATE A SIMPLE MODULE IN MAGENTO 2
  • 6. Step 1: Create configuration files 1.1. Create file: app/code/Tutorial/Example/etc/module.xml Purpose: Declare your module Source Code: (Go to our blog tutorial for full source code)
  • 7. Step 1: Create configuration files 1.2 Create file: app/code/Tutorial/Example/etc/frontend/routes.xml Purpose: Declare the router of module for frontend (Go to our blog tutorial for full source code)
  • 8. Step 2: Create controller, layout and template files 2.1 Create the controller file: app/code/Tutorial/Example/Controller/Index/Index.php => The souce code is found in our blog tutorial
  • 9. Step 2: Create controller, layout and template files 2.2 Create the layout file: app/code/Tutorial/Example/view/frontend/layout/example_inde x_index.xml (Go to our blog tutorial for full source code)
  • 10. Step 2: Create controller, layout and template files 2.3 Create the template file: app/code/Tutorial/Example/view/frontend/templates/index.phtml (Go to our blog tutorial for full source code)
  • 11. Step 3: Activate the module in the configuration file 3.1 Activate module by opening app/etc/config.php file then add this line “'Tutorial_Example' => 1” into it: (Go to our blog tutorial for full source code)
  • 12. Step 3: Activate the module in the configuration file 3.2 Open the Command in Windows (or the Terminal in Linux and MAC OS). Go to Magento root folder and run this command line to install module: binmagento setup:upgrade (Go to our blog tutorial for full source code)
  • 13. Step 3: Activate the module in the configuration file 3.3 Clear the Magento cache then access with url http://localhost/magento2/example/index/index/
  • 14. Following MageWorld Magento 2 Tutorial Series…