Magento 2, PHP

Magento module overview

Modules can be installed with Composer allowing their version management. All modules installed in such way are placed in the vendor/ folder and have next base structure

<vendor>/<vendor> / <type >-< module-name >. 

In this case can be:module - Magento module theme - admin or frontend themes language - language packs In a case when you have a very specific functionality or customization which is related to a specific project and there is no need to share it with other projects it should be created in the app/code/>vendor>/< type >-< module-name > directory and the required directories within it.### Module registration #Magento components, including modules, themes, and language packages, must be registered in the Magento system through the Magento ComponentRegistrar class. - [Magento DevDocs - Register your component (http://devdocs.magento.com/guides/v2.2/extension-dev-guide/build/component-registration.html)

Each component must have a file called registration.php in its root directory. For example, here is the registration.php file for Magento’s AdminNotification module. Depending on the type of component, registration is performed through registration.php by adding to it as follows: - Magento DevDocs - Register your component -

How to register modules - registration.php [1] use

\\Magento\\Framework\\Component\\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, \'<VendorName-->_< moduleName >\', __DIR__); 
  • how to register language packages - registration.php [2]
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, '<VendorName-->_<packagename>', __DIR__);
</packagename>
  • how to register themes - registration.php [3]
    use \Magento\Framework\Component\ComponentRegistrar;
    ComponentRegistrar::register(ComponentRegistrar::THEME, '< area-- >/< vendor >/< theme name= >', __DIR__);
  • composer.json autoload/files[] = registration.php [4]
{
    name: Dsg-vendor/bar-component,
    autoload: {
        psr-4: { DsgVendor\\BarComponent\\:  },
        files: [ registration.php ]
    } 
}
  • at what stage - when including vendor/autoload.php [5]
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Magento_Backend',
    __DIR__
);
    autoload: {
        files: [
            app/etc/NonComposerComponentRegistration.php
        ],
    }
Tags :