As Stable version of Magento2 is released, how should we create a new module? What are the exact steps required to create a new module in Magento2 stable version ? Is there any way to convert Magento2 Beta module into stable version module ?
Looking forward to hear your thoughts.
I finally found a successful way to create a new module in stable Magento2 version:
Below are the list of files that you need to create in order to create a new module, my package name is Ktpl and module name is Brandmanager for this case.
1) Create module.xml at app/code/Ktpl/Brandmanager/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Ktpl_Brandmanager" setup_version="2.0.0">
    </module>
</config>
2) Create composer.json at app/code/Ktpl/Brandmanager/composer.json
{
  "name": "ktpl/brandmanager",
  "description": "Brand manager adds the facility to manage store brands in Magento2",
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/module-store": "*",
    "magento/module-backend": "*",
    "magento/framework": "*"
  },
  "type": "magento2-module",
  "license": "GPL-3.0",
  "authors": [
    {
      "name": "KTPL",
      "email": "[email protected]"
    }
  ],
  "autoload": {
    "files": [
      "registration.php"
    ],
    "psr-4": {
      "Ktpl\\Brandmanager\\": ""
    }
  }
}
3) Create registration.php file at app/code/Ktpl/Brandmanager/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Ktpl_Brandmanager',
    __DIR__
);
After placing these files run below command from Magento root.
sudo php -f bin/magento setup:upgrade
sudo rm -rf var/cache/*
sudo rm -rf var/page_cache/*
sudo rm -rf var/generation/*
This process will successfully register your module and you would be able to see you module at store -> Configuration -> Advanced -> Advanced section.
I am not going to give you a step by step guide, this isn't the place for such a answer.
Most notable change recently are requiring a registration.php and composer.json in the module route
Eg.
https://github.com/magento/magento2/blob/develop/app/code/Magento/AdminNotification/composer.json
https://github.com/magento/magento2/blob/develop/app/code/Magento/AdminNotification/registration.php
I would just base your new module of the core, it is the easiest way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With