Drupal 8 Creating custom module from scratch

‘Drupal 8 Creating custom module steps

Costume Module file structure (My Drupal version 8.1.2)

drupal 8 custome module structure

1. Create a folder under ‘/modules/’ for this explanation I am creating a ‘example’ (this is our module folder) folder inside module folder

2. Create module info file ‘example.info.yml’ inside example folder

3. Create example.module inside example folder

4. Create example.routing.yml in example folder

The path: ‘/examp’ begin with 2 space catheters. Here we are defining the end point (http://localhost/examp [ I am using ‘localhost’ for development])

5. Create controller:- for creating controller first we need to create an ‘src’ folder inside example folder inside src folder create a ‘Controller’ folder and inside it create ExampleController.php

the controller full path will be like this ‘modules/example/src/Controller/ExampleController.php’

6. Install the new module from admin

drupal 8 module installation

7. Open your favorite internet browser  hit your example URL (in my case :  http://localhost/examp) you can see the generated page

drupal 8 module page


GitHub : https://github.com/bikeshm/drupal-8-module-sample1

Check how to create a custom block : http://wiki.workassis.com/drupal-8-creating-custom-block-from-scratch/


Author: bm on June 15, 2016
Category: Drupal 8

Your comment:

Your Name


Last articles