Start Creating Module Using Drupal Console
Drupal Console is a very powerful CLI tool. As soon as you’ll start using it, you will start loving it and being a developer will ease your life. It will provide you more time to think about logics :).
So let’s see how to create a module using CLI.
To check how to setup Drupal console
https://medium.com/@chaitanya06/drupal-console-cli-to-generate-boilerplate-code-d3dd52847ea1
To create a custom module, just open your terminal and go to your project root. As I have set up a drupal console within my project using command —
composer require drupal/console
So type a command -
vendor/bin/drupal gm
or
vendor/bin/drupal generate:module
It will start asking for inputs with default options. Likewise -
Enter the new module name:
> cli_module
It’s the name of my custom module. Then it asks for the machine name with the default value i.e [cli_module]
You can input other machine names as well.
Next, it will ask for the path of the module like it giving [modules/custom] followed by the module description. As given in the image below -
Rest all the by default options are self-explanatory. As you can see five files generated by CLI and generated a total of 87 lines of code.
Hope this will encourage you to start using the drupal console. And it will make your life easier and decrease your development efforts.
Keep Learning… Keep Sharing…
🙏