Magento 2.x Component & Registration.php File

Magento 2 component is set of (module, language, library, theme, setup etc), each component has unique identity.

  • Component module defines module Registration

//For Component Module Registration 

ComponentRegistrar::register(ComponentRegistrar::MODULE, '<VendorName_ModuleName>', __DIR__);
  • The Module component of registration.php looks as follows:
<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'VendorName_ModuleName',
    __DIR__
);
  • Component theme defines theme Registration
// For Component Theme Registration

ComponentRegistrar::register(ComponentRegistrar::THEME, '<area>/<vendor>/<theme name>', __DIR__);
  • The Theme component of registration.php looks as follows:


\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/vendor/custom-theme',
    __DIR__
);


  • Component Language defines Language Registration

// For Component Libraries Registration
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, '<VendorName>_<Language packageName>', __DIR__);
  • The Language component of registration.php looks as follows:


\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
    'vendor_sp_sp',
    __DIR__
);

  • Component library defines library Registration

// For Component Theme Registration 
ComponentRegistrar::register(ComponentRegistrar::THEME, '//', __DIR__);

Leave a Reply

Your email address will not be published. Required fields are marked *