![]() _controller: 'Drupal\hello_module\Controller\WelcomeController::welcome' Each route is defined as a machine name in the form of my_module_name.route_name (for example hello_module.welcome) hello_module.welcome: routing.yml file is created to define routes. Our file name: WelcomeController.php $bodyĪ route specifies the code that should be executed to generate the response when a URI is requested. Now let’s create a file in a folder structured as /src/Controller/WelcomeController.php The controller in our module is responsible for generating the body and sending it back to the page. They can perform one or more actions and return different results to a particular request. Controllers process user requests and determine the appropriate course of action. Step 4: Create a ControllerĬontrollers are responsible for controlling the flow of the application and its logic. Where the key is the name, the separator is ‘:’ (colon) and the value is “Hello Module”. info.yml file comprises 3 things: key, separator, value. Our file name: hello_ name: Hello Moduleĭescription: 'First custom drupal 9 module' info.yml file is created to notify Drupal about its existence in the system and provide information for the Drupal Web UI administration pages. info.yml file holds the module information, compatibility, and dependencies information.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |