<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Home on Module Builder</title><link>https://drupal-code-builder.github.io/module-builder-docs/</link><description>Recent content in Home on Module Builder</description><generator>Hugo</generator><language>en-uk</language><atom:link href="https://drupal-code-builder.github.io/module-builder-docs/index.xml" rel="self" type="application/rss+xml"/><item><title>Installation</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/installation/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/installation/</guid><description>&lt;h1 id="installation"&gt;Installation&lt;a class="anchor" href="#installation"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Module Builder is a Drupal module, and &lt;a href="https://www.drupal.org/docs/extending-drupal/installing-modules"&gt;is installed like any other module&lt;/a&gt;:&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install Module Builder using Composer:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;composer require drupal/module_builder&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enable the module in the UI on the Extend page, or with Drush.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to Administration › Configuration › Development › Module Builder › Analyse
code.&lt;/p&gt;
&lt;img src="screenshot-analysis-form.png" width="400px"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the &amp;lsquo;Update code analysis&amp;rsquo; button.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;blockquote class='book-hint success'&gt;
&lt;p&gt;You should run the code analysis again if you have enabled new modules,
updated modules, or added code to your custom modules, so that Module Builder
knows out new components in your codebase.&lt;/p&gt;</description></item><item><title>Create a module</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/create/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/create/</guid><description>&lt;h1 id="create-a-module"&gt;Create a module&lt;a class="anchor" href="#create-a-module"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;h2 id="new-module"&gt;New module&lt;a class="anchor" href="#new-module"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Go to Administration › Configuration › Development › Module Builder.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the &amp;lsquo;Add module&amp;rsquo; button.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter the human-readable name for your module. The machine name is derived
automatically, and you can choose to edit it, the same way as with any other
config entity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;That&amp;rsquo;s all you need to create the module entity. You can press the &amp;lsquo;Save&amp;rsquo;
button, or you can &lt;a href="https://drupal-code-builder.github.io/module-builder-docs/sections/info/"&gt;enter further details&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After you&amp;rsquo;ve saved the module, the form shows a number of tabs, each one for
different types of modules components. You can navigate between these tabs in
any order: each one is a form with its own save button. The different
sections of this guide describe each tab.&lt;/p&gt;</description></item><item><title>Info form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/info/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/info/</guid><description>&lt;h2 id="info-form"&gt;Info form&lt;a class="anchor" href="#info-form"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Info tab is the form initially used to create the module. It holds data that
goes in the module&amp;rsquo;s &lt;code&gt;info.yml&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;It also allows you to specify where the module will be written. By default,
modules are written to &lt;code&gt;modules/custom&lt;/code&gt;, but you can specify that the module is
a submodule inside another module, or a test module in another module&amp;rsquo;s test
code.&lt;/p&gt;
&lt;img src="info-location.png" width="800px"&gt;
&lt;p&gt;For more information on the info properties, see &lt;a href="https://www.drupal.org/docs/develop/creating-modules/let-drupal-know-about-your-module-with-an-infoyml-file"&gt;the info file
documentation&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Hooks form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/hooks/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/hooks/</guid><description>&lt;h1 id="hooks-form"&gt;Hooks form&lt;a class="anchor" href="#hooks-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Hooks tab lets you add hook implementations. These can be procedural
functions, or use the new object-oriented-style hooks which are methods in a
class.&lt;/p&gt;
&lt;h2 id="object-oriented-hooks"&gt;Object-oriented hooks&lt;a class="anchor" href="#object-oriented-hooks"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Object-oriented hooks are methods in a PHP class. These were &lt;a href="https://www.drupal.org/blog/drupal-11-1-0"&gt;introduced in
Drupal 11.1&lt;/a&gt;, and can be
backwards-compatible with older versions of Drupal.&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click the &amp;lsquo;Add a Hook classes item&amp;rsquo; button. This adds a new section to the
form for the hooks class. This shows:&lt;/p&gt;</description></item><item><title>Plugins form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/plugins/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/plugins/</guid><description>&lt;h1 id="plugins-form"&gt;Plugins form&lt;a class="anchor" href="#plugins-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Plugins tab lets you add plugins and plugin types.&lt;/p&gt;
&lt;h2 id="plugins"&gt;Plugins&lt;a class="anchor" href="#plugins"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The plugins section of the form lets you add plugins.&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the Plugin type form element, start typing part of the plugin type name to
filter the autocomplete dropdown. You can click on the documentation link for
a plugin type to read more about it on the Drupal API site.&lt;/p&gt;
&lt;img src="plugins-plugin-id-filter.png" width="400px"&gt;
&lt;blockquote class='book-hint tip'&gt;
&lt;p&gt;The plugin type names are obtained from the service names of the plugin
manager for each plugin type.&lt;/p&gt;</description></item><item><title>Entity types form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/entity_types/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/entity_types/</guid><description>&lt;h1 id="entity-types-form"&gt;Entity types form&lt;a class="anchor" href="#entity-types-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The entity types page lets you create new &lt;a href="https://www.drupal.org/docs/drupal-apis/entity-api/entity-types"&gt;content entity types and config entity
types&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="content-entity-types"&gt;Content entity types&lt;a class="anchor" href="#content-entity-types"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Content entities are stored in the site&amp;rsquo;s database, and are typically created by
site editors. They can have admin-created fields and revisions.
Nodes, taxonomy terms, media, path aliases, and users are all content entity
types.&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the Content entity types form section, click &amp;lsquo;Add Content entity type&amp;rsquo;.
This adds a form section for the entity type.&lt;/p&gt;</description></item><item><title>Routes &amp; forms form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/routes_forms/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/routes_forms/</guid><description>&lt;h1 id="routes--forms-form"&gt;Routes &amp;amp; forms form&lt;a class="anchor" href="#routes--forms-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Routes &amp;amp; forms tab lets you add components to do with forms and pages on
your site.&lt;/p&gt;
&lt;h2 id="routes"&gt;Routes&lt;a class="anchor" href="#routes"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The routes form section lets you add route items. (For dynamic routes, see
below).&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click the &amp;lsquo;Add a Routes item&amp;rsquo; button. This adds a new section to the form.&lt;/p&gt;
&lt;img src="routes-route-basics.png" width="400px"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter the route path. This must begin with a &amp;lsquo;/&amp;rsquo;. To pass parameters from the
path into your controller, enclose path components in braces, for example:
&lt;code&gt;/base-path/{parameter}&lt;/code&gt;. If the parameter name is an entity type ID, such as
&lt;code&gt;node&lt;/code&gt;, the controller parameter will be typed accordingly so that &lt;a href="https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/parameter-upcasting-in-routes"&gt;the
entity ID parameter is upcasted to an
entity&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Commands form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/commands/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/commands/</guid><description>&lt;h1 id="commands-form"&gt;Commands form&lt;a class="anchor" href="#commands-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Commands tab lets you add Drush commands, and on versions of Drupal core
since 11, Drupal CLI commands.&lt;/p&gt;
&lt;h2 id="cli-commands"&gt;CLI commands&lt;a class="anchor" href="#cli-commands"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Drupal CLI commands need only Drupal core to run, and are run with the &lt;code&gt;dr&lt;/code&gt;
shell command. These were &lt;a href="https://www.drupal.org/node/3584928"&gt;introduced in Drupal
11.4&lt;/a&gt;.&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &amp;lsquo;Add a Cli commands item&amp;rsquo;. This adds a form section for the command.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter the command name. This is the string that is typed to execute the
command.&lt;/p&gt;</description></item><item><title>Tests form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/tests/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/tests/</guid><description>&lt;h1 id="tests-form"&gt;Tests form&lt;a class="anchor" href="#tests-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Tests tab lets you add PHPUnit tests.&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &amp;lsquo;Add a PHPUnit test case class item&amp;rsquo;. This adds a form section for the
test class.&lt;/p&gt;
&lt;img src="tests-basic.png" width="400px"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select the &lt;a href="https://www.drupal.org/docs/develop/automated-testing/types-of-tests"&gt;test
type&lt;/a&gt;.
This determines the base class the test will use.&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;Unit test&lt;/dt&gt;
&lt;dd&gt;These are pure PHPUnit tests which don&amp;rsquo;t install Drupal. They run very fast
but do not have access to the database or Drupal&amp;rsquo;s APIS.&lt;/dd&gt;
&lt;dt&gt;Kernel test&lt;/dt&gt;
&lt;dd&gt;These install a basic Drupal site and can enable modules, but they do not
run the installation for any modules. &lt;a href="https://www.drupal.org/docs/automated-testing/phpunit-in-drupal/setup-tasks-in-kernel-tests"&gt;Tasks such as setting up entity types,
creating database tables, and installing default
config&lt;/a&gt;
will need to be done in the test. They have access to all of Drupal&amp;rsquo;s APIs,
and run fairly fast. It is possible to &lt;a href="https://www.drupal.org/docs/develop/automated-testing/phpunit-in-drupal/making-http-requests-programmatically-in-kernel-tests"&gt;make HTTP requests to the test site
and make simple assertions about the
response&lt;/a&gt;.&lt;/dd&gt;
&lt;dt&gt;Kernel test with entity support&lt;/dt&gt;
&lt;dd&gt;This is a kernel test as above, using EntityKernelTestBase as the test
class parent.&lt;/dd&gt;
&lt;dt&gt;Browser test&lt;/dt&gt;
&lt;dd&gt;This installs a full Drupal site, and allows HTTP requests to be made to
the test site using &lt;a href="https://mink.behat.org/en/latest/"&gt;Mink&lt;/a&gt;. These are
considerably slower than Kernel tests.&lt;/dd&gt;
&lt;dt&gt;JavaScript test&lt;/dt&gt;
&lt;dd&gt;These are like Browser tests, but additionally use Nightwatch to test
JavaScript functionality.&lt;/dd&gt;
&lt;dt&gt;Existing site test&lt;/dt&gt;
&lt;dd&gt;These make assertions against the existing site instead of installing a
test site. This requires the &lt;a href="https://git.drupalcode.org/project/dtt/"&gt;DTT&lt;/a&gt; package.&lt;/dd&gt;
&lt;/dl&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter the short class name of the test.&lt;/p&gt;</description></item><item><title>Miscellaneous form</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/misc/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/misc/</guid><description>&lt;h1 id="miscellaneous-form"&gt;Miscellaneous form&lt;a class="anchor" href="#miscellaneous-form"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Miscellaneous tab lets you various components, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Services&lt;/li&gt;
&lt;li&gt;Event subscribers&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;li&gt;Permissions&lt;/li&gt;
&lt;li&gt;Theme hooks&lt;/li&gt;
&lt;li&gt;Libraries&lt;/li&gt;
&lt;li&gt;Drush commands&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="services"&gt;Services&lt;a class="anchor" href="#services"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Services are classes which provide some sort of API, and &lt;a href="https://www.drupal.org/docs/drupal-apis/services-and-dependency-injection/services-and-dependency-injection-in-drupal"&gt;which are obtained from
the service container&lt;/a&gt;.&lt;/p&gt;
&lt;div class="book-steps"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &amp;lsquo;Add a services item&amp;rsquo;. This adds a form section for the service.&lt;/p&gt;
&lt;img src="misc-services.png" width="400px"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optionally, select a service type. This adds a &lt;a href="https://www.drupal.org/docs/drupal-apis/services-and-dependency-injection/service-tags"&gt;service
tag&lt;/a&gt;
to your service, and makes your service implement a particular API, and the
service will typically be collected by another service and its methods called
by the collector.&lt;/p&gt;</description></item><item><title>Generate page</title><link>https://drupal-code-builder.github.io/module-builder-docs/sections/generate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupal-code-builder.github.io/module-builder-docs/sections/generate/</guid><description>&lt;h1 id="generate-page"&gt;Generate page&lt;a class="anchor" href="#generate-page"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Generate tab generates the code based on the data entered for the module,
and lets you write the code files.&lt;/p&gt;
&lt;p&gt;You can generate code at any time, and you can edit the module&amp;rsquo;s options and
return to the Generate tab to generate code again.&lt;/p&gt;
&lt;p&gt;Some types of component will merge with existing code; for others, you will need
to use version control if there is an existing file for the component.&lt;/p&gt;</description></item></channel></rss>