Book Image

Drupal 10 Masterclass

By : Adam Bergstein
Book Image

Drupal 10 Masterclass

By: Adam Bergstein

Overview of this book

Learning Drupal can be challenging because of its robust, extensible, and powerful capability for digital experiences, making it difficult for beginners to grasp and use it for application development. If you’re looking to break into Drupal with hands-on knowledge, this Drupal 10 Masterclass is for you. With this book, you’ll gain a thorough knowledge of Drupal by understanding its core concepts, including its technical architecture, frontend, backend, framework, and latest features. Equipped with foundational knowledge, you’ll bootstrap and install your first project with expert guidance on maintaining Drupal applications. Progressively, you’ll build applications using Drupal’s core features such as content structures, multilingual support, users, roles, Views, search, and digital assets. You’ll discover techniques for developing modules and themes and harness Drupal’s robust content management through layout builder, blocks, and content workflows. The book familiarizes you with prominent tools such as Git, Drush, and Composer for code deployments and DevOps practices for Drupal application management. You’ll also explore advanced use cases for content migration and multisite implementation, extending your application’s capabilities. By the end of this book, you’ll not only have learned how to build a successful Drupal application but may also find yourself contributing to the Drupal community.
Table of Contents (31 chapters)
1
Part 1:Foundational Concepts
7
Part 2:Setting up - Installing and Maintaining
10
Part 3:Building - Features and Configuration
12
Chapter 9: Users, Roles, and Permissions
17
Part 4:Using - Content Management
21
Part 5:Advanced Topics
Appendix A - Drupal Terminology

Automating deployments across many sites

When leveraging multisite, it is important to consider automation. Updating every site in a large-scale Drupal multisite implementation would be difficult, especially given the frequency with which updates happen.

Drush provides helpful commands to manage this.

$ drush site:alias > list-of-sites.txt

The preceding command prints a list of site aliases for a Drupal application (https://www.drush.org/12.x/commands/site_alias/).

$ while read s; do \
drush sql-dump > backup-$s.sql \
drush "@$s" deploy \
done <list-of-sites.txt

This small script takes the results of each alias from the previous command and performs a deployment. While it is a simple example, a script could then invoke rollback logic upon error.

$ if grep -Fxq "error" list-of-sites.txt \
then \
while read s; do \
drush "@$s" sql-import -y < backup-$s.sql \
done <list-of-sites.txt \
fi

It is highly recommended that you stage...