In below steps, you will get how to create a basic extension. Before we start, there are some requirements that we need to check.
- You must have the latest Magento 2 version installed in your system.
- You need to disable the Magneto Cache: It needs to be done so that you can save some time on the manual flush system when you make changes in the codes.
- Select developer mode: It lets you see all the errors from Magento’s end.
Steps to create Extension:
- Create a folder in app/code/Techgroup/Addon
- Create registration.php file here with following contents
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Techgroup_Addon', __DIR__ );
- Create composer.json file in same folder. Update your correct values where is “************”.
{ "name" : "techgroup/addon", "description" : "Techgroup Addon", "type" : "magento2-module", "version" : "1.0.0", "license" : "GPL", "authors" : [{ "name" : "**************", "email" : "**********", "homepage" : "************", "role" : "Developer" } ], "autoload" : { "files" : [ "registration.php" ], "psr-4" : { "Techgroup\\Addon\\" : "" } } }
- Create another folder app/code/Techgroup/Addon/etc.
- Create a module.xml in this folder with following content.
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Techgroup_Addon" setup_version="1.0.0"> <sequence> <module name="Magento_Backend"/> <module name="Magento_Sales"/> <module name="Magento_Quote"/> <module name="Magento_Checkout"/> <module name="Magento_Cms"/> </sequence> </module> </config>
- Create another file di.xml if needed to override classes.
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> </config>
- Some other files and folder you can create like app/code/Techgroup/Addon/etc/frontend, app/code/Techgroup/Addon/etc/adminhtml etc.
- Run deploy commands
sudo php bin/magento setup:upgrade sudo php bin/magento setup:static-content:deploy -f sudo php bin/magento indexer:reindex sudo php bin/magento setup:di:compile