In Magento 2, modules will be created in app/codeof a Magento root directory, with this format: app/code/vendor name/module name. Now we will follow this step to create a simple module which work on Magento 2 and display Demo Module

Step 1: Create the folder of Demo module. 

Name of the module is defined as VendorName_ModuleName.

First part is name of the vendor and last part is name of the module: For example:  

App/code/Anyhowinfo/Demo where Anyhowinfo is vendor name while Demo is module name. 

Step 2: Create etc/module.xml file. 

Now we create module in App/code/Anyhowinfo/Demo/etc/module.xml file 

And the file format is given below. 

Copy to Clipboard

Step 3: Create Demo/registration.php file 

Now we create registration file in App/code/Anyhowinfo/Demo/registration.php 

And the file format is given below. 

Copy to Clipboard

Step 4: Enable the module. 

Now we are going to enable module by following step: – 

Run the below command to see the status of module. 

php bin/magento module:status 

You see that your module Anyhowinfo_Demo is disable now. 

For enable the module you created run the below command: – 

php bin/magento module:enable. 

Or the shortcut method to enable module in magento.  

Open the app/etc/config.php and search your module name. 

Your module shows like this: – ‘Anyhowinfo_Demo’ => 0, 

Change into ‘Anyhowinfo_Demo’ => 1, 

Now your module is enabled. 

After all the steps please upgrade your database by running 

php bin/magento setup:upgradefrom the Magento root directory. 

Now see that your UI interface is broken   

Please run the below deploy command line to fix it. 

php bin/magento setup:static-content:deploy -f 

After this, please run php bin/magento cache: cleanto check the result.