Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Drupal 10 Masterclass

You're reading from  Drupal 10 Masterclass

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781837633104
Pages 310 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Adam Bergstein Adam Bergstein
Profile icon Adam Bergstein

Table of Contents (31) Chapters

Preface 1. Part 1:Foundational Concepts
2. Chapter 1: What is Drupal? 3. Chapter 2: Drupal Core, Modules, and Themes 4. Chapter 3: Infrastructure and Overview of Technical Architecture 5. Chapter 4: Drupal Community 6. Chapter 5: What’s New in Drupal 10 7. Part 2:Setting up - Installing and Maintaining
8. Chapter 6: Bootstrapping, Installing, and Configuring a New Drupal Project 9. Chapter 7: Maintaining Drupal 10. Part 3:Building - Features and Configuration
11. Chapter 8: Content Structures and Multilingual 12. Chapter 9: Users, Roles, and Permissions 13. Chapter 10: Drupal Views and Display Modes 14. Chapter 11: Files, Images, and Media 15. Chapter 12: Search 16. Chapter 13: Contact Forms 17. Part 4:Using - Content Management
18. Chapter 14: Basic Content Authoring Experience 19. Chapter 15: Visual Content Management 20. Chapter 16: Content Workflows 21. Part 5:Advanced Topics
22. Chapter 17: Git, Drush, Composer, and DevOps 23. Chapter 18: Module Development 24. Chapter 19: Theme Development 25. Chapter 20: Delivering Drupal Content through APIs 26. Chapter 21: Migrating Content into Drupal 27. Chapter 22: Multisite Management 28. Index 29. Other Books You May Enjoy Appendix A - Drupal Terminology

Git, Drush,
Composer, and DevOps

Much of the book so far has covered installing and configuring Drupal to meet a variety of use cases. However, even if you are not a developer, it can be difficult to maintain a Drupal application or contribute to the community without some basic technical skills. While this is an advanced topic, a brief primer in technologies such as Git, Drush, and Composer that enable developers can serve as a foundational launchpad into future development practices. These technologies bridge development and operations through practices known as DevOps. Getting started with this technology helps work toward the 80/20 rule, as discussed in previous chapters.

In this chapter, we’re going to cover the following main topics:

  • Git basics
  • Drush basics
  • Composer basics
  • DevOps practices

Technical requirements

This chapter moves beyond installing, using, and configuring Drupal. Many of the items in this chapter run on the command line through a terminal and are well-suited for Mac and Linux machines. Support for Windows exists, but Mac and Linux have well-vetted paths adopted by many in the Drupal community.

Technical requirements change by tool. For instance, Git may have certain system dependencies that are different from a PHP-based tool such as Composer. Much of the requirements are abstracted by installers that run on the local operating system and set up the tools.

Some commands may require Secure Shell (SSH), either to access a machine remotely or for use by the tool on the local system to connect to remote systems. This is often important for connecting to environments that run Drupal applications or working with code repositories. Configuring SSH often needs to be set up locally and on remote systems. Some SaaS vendors offer user interfaces that allow...

Git basics

Git is a distributed code versioning system. A repository is what stores the code, which is revised by changes known as commits. Each repository can configure remotes, which help synchronize code between repositories by fetching code from one repository to another. Remotes communicate via HTTPS with basic authentication credentials or the SSH protocol, which can leverage SSH keys. There is significant documentation on the internet on generating SSH keys and configuring SSH in Git that changes, based on operating systems and hosted Git platforms. Repositories maintain branches that help maintain a series of commits that relate to a change. Code in a branch is often merged into a main branch, which serves as a baseline for code to be accepted into a repository.

SaaS vendors have helped make Git more ubiquitous. Vendors such as GitHub and GitLab run managed Git repositories with a UI and various complementary features. It is common for a Drupal application to manage code...

Drush basics

Drush is a command-line tool that runs operations on a Drupal site. Because Drupal has a backend administrative area, users with the appropriate permissions can log in and operate a Drupal application. However, there are times when an application is unavailable, such as when it has pending database updates or requires a cache clear. Also, developers want to be able to run commands remotely and in scripts during events such as code deployments, without having to subsequently log in through the web application.

Operations is an overloaded term in technology, but with Drush, operations are focused on actions that run on the Drupal application – things such as logging in as a user, clearing the cache, or updating configuration from code to the application. Drush does not manage code in Drupal.

Like Git, Drush can leverage SSH to manage remotes. This feature is known as site aliases in Drush. Site aliases are helpful for developers who work on multiple Drupal applications...

Composer basics

Composer is a command-line tool for managing code in PHP-based applications such as Drupal. PHP has a vast ecosystem of components, libraries, and so on, including the catalog of Drupal projects and various Symfony components used by Drupal. Like a package manager, Composer helps assemble and update the PHP-based parts of an application.

Composer starts with a project. Not to be confused with a Drupal project, a Composer project is the high-level scaffolding for an application. Drupal applications are initialized as a Composer project. Composer projects have installed packages, and each package has its own dependencies – all of which can be managed by Composer through Composer projects.

Once a Composer project is initialized, Composer has a few key constructs. A composer.json file manages a developer-friendly list of projects, versions, and constraints for the Drupal application. A constraint in Composer is a set of directives defined per project to help...

DevOps practices

Historically, software engineers would delegate management, coordination, and execution of releases to operators. The practice of DevOps brought those practices together, primarily through continuous learning and the use of automation. Summarizing DevOps can be challenging, given it spans a set of practices and technologies that enable that practice. At a high level, it manages operations in code through configuration and scripts. Both development and operations teams can perpetually learn from issues that arise and update code based on that knowledge. This philosophy promotes consistency, given the same code is used repeatedly to perform the same actions on repeat.

Drupal best practices have evolved as DevOps has become more emergent. DevOps for Drupal applications closely align with events found in GitOps, practices tied to continuous integration, and the desire to have repeatable and frequent code deployments. Developer workflows often create new branches, review...

Summary

Git, Drush, and Composer all are tools that Drupal developers are required to learn. Each of the tools handles different aspects of development. Git manages distributed code versioning from local systems through deployments. Drush manages operations that run on Drupal applications. Composer manages Drupal’s projects, dependencies, and code. All of these can be combined to do automation, which is common for consistency in code deployments.

The next chapter explores creating custom modules with Drupal’s development framework.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Drupal 10 Masterclass
Published in: Dec 2023 Publisher: Packt ISBN-13: 9781837633104
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}