layout | group | subgroup | title | menu_title | menu_order | github_link | redirect_from |
---|---|---|---|---|---|---|---|
default |
extension-dev-guide |
03_Build |
Create your component file structure |
Create your component file structure |
3 |
extension-dev-guide/build/module-file-structure.md |
/guides/v2.0/extension-dev-guide/module-file-structure.html |
##{{page.menu_title}}
Magento 2 looks for the files that make up a component, including configuration files, in particular places inside the module file structure. Follow the predefined file structure to ensure that your module works as expected.{% include php-dev/component-root.md %}
The following topics discuss a typical file structure for the following components:- Magento 2 module file structure
- Magento 2 theme file structure
- Magento 2 language package file structure
####Typical directories Typical module directories are:
Block
: contains PHP view classes as part of MVC vertical implementation of module logic.Controller
: contains PHP controller classes as part of MVC vertical implementation of module logic.etc
: contains configuration files; in particular,module.xml
, which is required.Model
: contains PHP model classes as part of MVC vertical implementation of module logic.Setup
: contains classes for module database structure and data setup which are invoked when installing or upgrading.
####Additional directories Additionally, there are directories for configuration and other ancillary functions for items like plug-ins, internationalization, and layout files.
Api
: contains any PHP classes exposed to the API.i18n
: contains localization files.Plugin
: contains any needed plug-ins.view
: contains view files, including static view files, design templates, email templates, and layout files.
├── composer.json
├── etc
│ └── view.xml
├── i18n
│ └── en_US.csv
├── LICENSE_AFL.txt
├── LICENSE.txt
├── media
│ └── preview.jpg
├── registration.php
└── web
├── css
│ ├── email.less
│ ├── print.less
│ ├── source
│ │ ├── _actions-toolbar.less
│ │ ├── _breadcrumbs.less
│ │ ├── _buttons.less
│ │ ├── components
│ │ │ └── _modals_extend.less
│ │ ├── _icons.less
│ │ ├── _layout.less
│ │ ├── _theme.less
│ │ ├── _tooltips.less
│ │ ├── _typography.less
│ │ └── _variables.less
│ ├── _styles.less
│ ├── styles-l.less
│ └── styles-m.less
├── images
│ └── logo.svg
└── js
├── navigation-menu.js
├── responsive.js
└── theme.js
####Typical directories Typical theme directories are:
-
etc
:view.xml
contains image configurations for all images and thumbnails. -
i18n
: Translation dictionaries, if any. -
media
: Theme preview (a screen capture of your theme). -
web
: Optional directory that contains static files organized into the following subdirectories:css/source
: Theme'sless
configuration files that invoke mixins for global elements from the Magento UI library, and thetheme.less
file that overrides the default variables values.css/source/lib
: View files that override the UI library files stored inlib/web/css/source/lib
fonts
: Fonts for your theme.images
: Static images.js
: JavaScript files.
{% include php-dev/lang-pack-file-struct.md %}
####Next [Register your component]({{ site.gdeurl }}extension-dev-guide/build/component-registration.html)