The new Magento module architecture
Much like Magento 1.0, Magento 2 is divided into modules. These modules are meant to encapsulate functionality related to a certain business feature. The framework provides organization for these modules, which can be found in the app/code
directory with the following convention: app/code/(vendor)/(modulename)
.
Under the (modulename)
directory, there are a series of nested directories that contain the blocks, helpers, controllers, and models that make up a module. The hierarchy looks like this:
The following is a brief description of these directories and the programmatic roles of the files they contain:
Block/
: This directory has PHP classes that contain logic to manage the view template. Blocks, therefore, are fundamentally related to display logic and are key to managing this logic.Controller/
: This directory contains controllers for the module. A controller is responsible for routing requests in Magento, and...