Create custom module

  1. Create new folder under Module folder with the module name. eg: Module/custommodule
  2. Create 3 file under custommodule as below: -
Place this code into above file
   Name: custommodule
   Type: module
   Description: 'custommodule'
   Package: Custom
   Core: 8.x

No need to give any code into above file -- leave it blank

Place this code into above file
     path: '/custommodule'
       _title: 'custommodule'
       _permission: 'access content'

3. Create controller directory: custommodule > src > controller
4. Under controller folder, create file name custommoduleController.php

Place this code into above file

   namespace Drupal\custommodule\Controller;
   class custommoduleController {
   public function custommodule() {
   return array(
   ‘#title’ => 'custommodule’,
   ‘#markup’ => ‘Content for custommodule.’

5. Enable the custommodule

Note: Replace custommodule with your module name

That is the very basic custom module for practice purpose, but we can create more complex module according to our need.

Source: -

YourTube: -