{"id":7661,"date":"2015-05-14T11:16:17","date_gmt":"2015-05-14T08:16:17","guid":{"rendered":"http:\/\/blog.belvg.com\/?p=7661"},"modified":"2025-06-30T22:12:01","modified_gmt":"2025-06-30T20:12:01","slug":"general-module-structure-in-magento-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html","title":{"rendered":"Magento 2 Module Structure"},"content":{"rendered":"\n<p>In order to understand how a module works we need to find out how basic components like controller, model, block and view interact with each other. If you have already worked with Magento before you should know why we need these structural units and how the module structure was organized in previous Magento versions.<!--more--><\/p>\n<p>It all looked like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter wp-image-10051 size-full\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/05\/mod_str11.png\" alt=\"mod str11\" width=\"466\" height=\"413\" title=\"Magento 2 Module Structure\"><\/p>\n<p>As we can see from this picture the module code was scattered across different directories (code, design, skin, etc).<\/p>\n<p>A module in Magento 2 is located in a single directory which simplifies the search and analysis of the extension&rsquo;s logic. &nbsp;Now the standard module structure looks like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter wp-image-10052 size-full\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/05\/mod_str2.png\" alt=\"mod str2\" width=\"447\" height=\"354\" title=\"Magento 2 Module Structure\"><\/p>\n<p>Let&rsquo;s describe this structure. Once again all extensions are located in the app \/ code \/. Then the following logic works:<\/p>\n<ul>\n<li><strong>Example<\/strong> &ndash; it is a vendor&rsquo;s name (as a rule it coincides with the company name and should be unique).<\/li>\n<li><strong>Extension<\/strong> &ndash; module (extension) name.<\/li>\n<\/ul>\n<p>The module includes the following:<\/p>\n<ul>\n<li><strong>Block<\/strong>&nbsp;&ndash; stores files that will ensure the interaction of the patterns (phtml from the View directory) with extension models or the whole system (optional directory).<\/li>\n<li><strong>Controller<\/strong> &ndash; these files are responsible for the connection of the module with the outside world &ndash; i.e. switching on the module by clicking on an url. (Example site.com\/extension\/index\/index &ndash; lead to the module controller. (optional directory).<\/li>\n<li><strong>etc<\/strong> &ndash; contains the configuration files.<\/li>\n<li><strong>Helper<\/strong>&nbsp;&ndash; contains the files that are responsible for performing general tasks for extension objects and variables.<\/li>\n<li><strong>Model<\/strong> &ndash; contains the files that are responsible for connection with the database (optional directory).<\/li>\n<li><strong>Setup<\/strong> &ndash; includes the files that are necessary to make changes in the database &ndash; i.e. creating tables, fields, or other records required for the module performance (optional directory).<\/li>\n<li><strong>Test&nbsp;<\/strong>&ndash; contains the files that are necessary to perform the module test. (optional directory).<\/li>\n<li><strong>View<\/strong> &ndash; includes the files that are necessary for information output on the frontend and backend. &nbsp;Commonly these files contain html code (optional directory).<\/li>\n<\/ul>\n<p>Understanding the module structure in Magento 2 allows analysis of the extension&rsquo;s logic and performance as well as an easier job finding and fixing arising errors and conflicts.<\/p>\n\n","protected":false},"excerpt":{"rendered":"In order to understand how a module works we need to find out how basic &#8230;","protected":false},"author":42,"featured_media":10049,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,389],"tags":[3,382,64,83],"class_list":["post-7661","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento","category-magento2-development","tag-magento","tag-magento-2-0","tag-module","tag-module-structure","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"In order to understand how a module works we need to find out how basic components like controller, model, block and view interact with each other.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Aliaksei Hryharenka\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#article\",\"name\":\"General Module Structure in Magento 2.0 | BelVG Blog\",\"headline\":\"Magento 2 Module Structure\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/2magento-module-structure.png\",\"width\":683,\"height\":170},\"datePublished\":\"2015-05-14T11:16:17+02:00\",\"dateModified\":\"2025-06-30T22:12:01+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#webpage\"},\"articleSection\":\"Magento, Magento 2 Development, magento, magento 2.0, module, module structure, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"position\":2,\"name\":\"Magento\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#listItem\",\"name\":\"Magento 2 Module Structure\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#listItem\",\"position\":3,\"name\":\"Magento 2 Module Structure\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko\",\"name\":\"Aliaksei Hryharenka\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bc7dc67af8fb059c80185d983bee2fdba6e6500979e4cb118ee4ba0de94c7837?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Aliaksei Hryharenka\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html\",\"name\":\"General Module Structure in Magento 2.0 | BelVG Blog\",\"description\":\"In order to understand how a module works we need to find out how basic components like controller, model, block and view interact with each other.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/2magento-module-structure.png\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html\\\/#mainImage\",\"width\":683,\"height\":170},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/general-module-structure-in-magento-2.html#mainImage\"},\"datePublished\":\"2015-05-14T11:16:17+02:00\",\"dateModified\":\"2025-06-30T22:12:01+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"General Module Structure in Magento 2.0 | BelVG Blog","description":"In order to understand how a module works we need to find out how basic components like controller, model, block and view interact with each other.","canonical_url":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#article","name":"General Module Structure in Magento 2.0 | BelVG Blog","headline":"Magento 2 Module Structure","author":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/05\/2magento-module-structure.png","width":683,"height":170},"datePublished":"2015-05-14T11:16:17+02:00","dateModified":"2025-06-30T22:12:01+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#webpage"},"articleSection":"Magento, Magento 2 Development, magento, magento 2.0, module, module structure, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","position":2,"name":"Magento","item":"https:\/\/belvg.com\/blog\/category\/magento","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#listItem","name":"Magento 2 Module Structure"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#listItem","position":3,"name":"Magento 2 Module Structure","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author","url":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko","name":"Aliaksei Hryharenka","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/bc7dc67af8fb059c80185d983bee2fdba6e6500979e4cb118ee4ba0de94c7837?s=96&d=mm&r=g","width":96,"height":96,"caption":"Aliaksei Hryharenka"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#webpage","url":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html","name":"General Module Structure in Magento 2.0 | BelVG Blog","description":"In order to understand how a module works we need to find out how basic components like controller, model, block and view interact with each other.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/05\/2magento-module-structure.png","@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html\/#mainImage","width":683,"height":170},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html#mainImage"},"datePublished":"2015-05-14T11:16:17+02:00","dateModified":"2025-06-30T22:12:01+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"7661","title":"General Module Structure in Magento 2.0 | #site_title","description":"In order to understand how a module works we need to find out how basic components like controller, model, block and view interact with each other.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:54","updated":"2026-11-03 18:37:54"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento\" title=\"Magento\">Magento<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tMagento 2 Module Structure\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento","link":"https:\/\/belvg.com\/blog\/category\/magento"},{"label":"Magento 2 Module Structure","link":"https:\/\/belvg.com\/blog\/general-module-structure-in-magento-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/7661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=7661"}],"version-history":[{"count":1,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/7661\/revisions"}],"predecessor-version":[{"id":29662,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/7661\/revisions\/29662"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/10049"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=7661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=7661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=7661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}