How to export configuration for a quickstart module during pull request creation - az-digital/az_quickstart GitHub Wiki
Context
Oftentimes we need to add configuration as code in order to create a new feature that is to be distributed in Quickstart. When developing for Quickstart, we use local development tools like ddev or lando. The quickstart development tooling (ddev and lando configuration) comes with things like
- PHPUnit
- PHPStan
- ESLint
- Prettier
- Theme Debug mode
- Drush
- Drupal Console
You can see all of the available lando tooling, simply by typing lando
and pressing the return key within your Command Line Interface (CLI) console.
In this tutorial, we will be using Drupal Console to export configuration that we will then include in a pull request.
First we need to download and install the Quickstart codebase, and create a new branch using an issue number.
Then we need to turn on lando, or ddev
Then install quickstart in the containers that lando or ddev provide.
Now we can navigate around our local development site as if it is a site online.
What is configuration as code?
Tip: Generally you know that you will need to export configuration if you see a machine name setting when editing the configuration.
Other times, it isn't clear that you are creating config, however, you should be able to deduce that something is config and will need to export it, if it is NOT content. One example of this is when changing entity type display settings.
How to export config for use in Quickstart.
Edit some config Figure out what kind of config you are editing or adding Export it.
From within your downloaded copy of Quickstart where you installed Quickstart.
For example you can export a view into az_core into the config/install folder like this via the CLI.
Note: With the upgrade to Drupal 10, the following command will no longer work because Drupal Console was removed. See https://github.com/drush-ops/drush/issues/5621
lando drupal config:export:single --module=az_core --remove-uuid --remove-config-hash -n --name=views.view.az_newsletter
Notice that I am not adding the .yml file extension to the end of the configuration name.
For new config, you can just do
git status
For existing config
git diff
And you will see what has changed. See lando drupal config:export:single --help
for more information about this command.
Finding hidden configuration
Sometimes you just can't figure out where the config you need is being set. The fool-proof way of figuring this out is to install all modules you need on a separate fresh install of Quickstart and export the entire site's configuration.
Then export the config for the site you are working on with the change you need already configured and compare the two.
Exporting an entire site's configuration can be done via the UI at /admin/config/development/configuration/full/export
, or the via command line via drush config-export
On a Mac, you can compare fairly easily using the CLI, or a GUI CLI
diff -rq folder1 folder2
XCode comes with the Filemerge App, which can be used to compare directories, among other things.