Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Download Tracker 1.0.7 — Minor update available for module download_tracker (1.0.7). Release: Directory2Block Slideshow 1.0.8 — Minor update available for module directory2block_slideshow (1.0.8). Release: Mautic Audiences 1.1.5 — Minor update available for module mautic_audiences (1.1.5). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

This is an example module, explaining step by step how you can create
your own drush generate command.

Workings with drush 10.x

Do not enable this module in production environment!

Example:

drush generate gnform

BACKGROUND:

---------------------

This module was inspired by Louis Nagtegaal - article and Jacob Rockowitz - module.

As Louis mentioned in his article:

For Drupal site builders, drush is the Swiss army knife that can be used for a wide range of purposes, from simply clearing the cache to updating translations or even installing a complete new site.

In the more recent versions of drush, a command was added that makes drush also interesting for Drupal developers.
This command, generate, makes it easy to generate boilerplate code for modules, plugins, services and much more.
And it is even possible to extend existing custom (or contrib) modules with a generator.

The generate command use chi-teck/drupal-code-generator-library.

What I really like about the Drush Generate command is that it allows you to generate specific templates based on user answers, those questions usually include the machine name of the module you want to add the code to, the machine name of the plugin that is created, which services you want to inject or which routes you want to add, etc...

After some research and due to the lack of documentation on how to create your own drush generate command, I decided to create a custom module explaining in detail how you can generate your custom code using the drush generate feature.

I will use Examples for Developers module as an example.

GOAL

------------
Developers can learn how to generate custom blueprint templates
by experimenting with those examples, and adapt them for their own use.

How can you help?

------------------
I'm glad you asked:

Most of all, we need you to file an issue every time you find an error or ambiguity or something that could be presented better.
* We need additional examples.
* We need reviews, corrections, and improvements to existing code.
* We need improvements in the documentation.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Jun 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.0.3 Stable Jun 30, 2023
2.0.x-dev Dev Jun 30, 2023
1.0.x-dev Dev Jun 28, 2023
1.0.2 Stable Jun 28, 2023
1.0.1 Stable Jun 28, 2023
1.0.0 Stable Jun 28, 2023