Book Image

Drupal 8 Configuration Management

Book Image

Drupal 8 Configuration Management

Overview of this book

Table of Contents (16 chapters)
Drupal 8 Configuration Management
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Coding standards


When developing for Drupal, it is not only a best practice to follow the Coding Standards for configuration (https://www.drupal.org/coding-standards/config), but it is also one of the things you need to internalize in your daily work. Of course, the Coding Standards do not apply to PHP only; there are even some guidelines for writing schema files.

The first rule of thumb is to simply follow the code style of the .yml files, as seen everywhere else in Drupal code. The key points are as follows:

  • Add a comment to the file, explaining the purpose and the content of this file. If there is only one schema file in your module, you may use a comment such as # Schema for the configuration files of the {YOURMODULENAME} module.

  • Do not use double quotes for strings; use single quotes whenever you need to wrap strings in quotes.

  • Use single quotes for label values that have only one word, for consistency.

  • Key definitions and types should never be put in quotes. According to the Drupal standard...