Skip to content

Create Magento 2 Module (Basic) Part I

here my first step to understanding magento 2 module development by create hello world extension, haha:

  1. create file app/code/Ansyori/HelloWorld/etc/module.xml
  2. here module.xml file 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="Ansyori_HelloWorld" setup_version="0.0.0">
        </module>
    </config>
  3. then create module registration file,  app/code/Ansyori/HelloWorld/registration.php
  4. <?php
    \Magento\Framework\Component\ComponentRegistrar::register(
        \Magento\Framework\Component\ComponentRegistrar::MODULE,
        'Ansyori_HelloWorld',
        __DIR__
    );
    ?>
  5. run follwing command use shell/command promp
  6. “php D:\xampp\htdocs\magento21\bin\magento setup:upgrade”
  7. or “D:\xampp\php\php  D:\xampp\htdocs\magento21\bin\magento setup:upgrade”
  8. if still not work, go to app\etc\config.php, edit the file
  9. <?php
    return array (
      'modules' => 
      array (
        'Ansyori_HelloWorld' => 1, 
        'Magento_Store' => 1,
        .............
  10. clear magento cache, at System->Cache Managements->Flush Magento Cache
  11. you will see your new module listed at Store->Setting->Configuration->Advanced->Advanced
Share

Comments are closed.