How to create basic frontend module in Magneto 2 ??
Step 1. Decide a name space(Extendtree) & module name(Helloworld). Ex. Extendtree_Helloworld
Step 2. create directory as: magento2/app/code/Extendtree/Helloworld
Step 3. Add a xml file named "module.xml" in directory: magento2/app/code/Extendtree/Helloworld/etc/module.xml
Step 4. Create a registration.php in directory: magento2/app/code/Extendtree/Helloworld/registration.php
Step 5. Now we have to enable our module, we have two ways to do this.
Enable module from config.php (located in directory magento2/app/etc/config.php )
Or First run the command php bin/magento module:status to checked out enable modules in our magento2
To enable module use the command php bin/magento module:enable Extendtree_Helloworld
Step 6. Just after step 5 you have to execute a command bin/magento setup:upgrade
Else our magento site will through an error as Please upgrade your database: Run “bin/magento setup:upgrade” from the Magento root directory.
Step 7. Now our module is fully configured with magento system. To confirm this check in backend :Store->Configuration->Advanced
Step 8. Now create routers for your module. First add routes.xml in directory magento2/app/code/Extendtree/Helloworld/etc/frontend/routes.xml
Step 9. Add controller to handle the requests in directory magento2/app/code/Extendtree/Helloworld/Controller/Test/Helloworld.php
Step 10. Now open URL : http://__BASEURL__/extendtree/test/helloworld
Here is how the URL composed: http://__BASEURL__/route_id/controller_name/front_name
Thank you..!!
"The easy way for everything."
No comments :
Post a Comment