Decisions about drupal
Architectural decision records tagged with drupal
-
acceptedAlways provide editors control over image style cropping
Manual user intervention can help prevent automated cropping from eliminating the most important parts of a photo.
-
acceptedUse data-drupal-selector to target form elements in JavaScript
Classes and IDs are unstable JavaScript targets in Drupal, while data-drupal-selector is a stable hook provided by the Form API.
-
acceptedUse Tagify for entity autocomplete widgets in Drupal
Drupal's default entity reference autocomplete widget has limited UX. A modern, well-supported replacement is needed and the Tagify module has been successfully used in several Lullabot projects.
-
acceptedOnly allow developers and site administrators access to the default Drupal files listing
Drupal's built-in files listing at
/admin/content/filesis a technical tool that has caused editorial confusion and accidental data loss. -
acceptedUse PHPStan for PHP code static analysis at level 6
Static analysis catches type errors, logic bugs, and unsafe code paths without running the application, improving code quality at low cost.
-
acceptedUse 'drush deploy' when building Drupal sites
When updating Drupal code and configuration in a given environment, it's useful to make sure all members of the team and all teams follow a consistent set of steps, in the same order. Having consistent steps across multiple projects will reduce onboarding for new team members.
-
acceptedUse the term "microcontent" to describe embeddable content from the same website
Teams have used inconsistent terminology — including "micro-content", "component", "embeds", and "inline content" — to describe content that is embedded within pages but never exists independently.
-
acceptedUse `access_unpublished` for password-protected pages
Some pages need to be accessible only to specific groups or individuals using a password or token, without requiring a full user account.
-
acceptedUse Renovate for third-party dependency updates
Renovate supports automatic updates across a wide variety of ecosystems ensuring our projects are secure and up to date.
-
acceptedUse human-readable names as exposed filter identifiers in Views
-
acceptedEnforce Twig coding standards with automatic linting
Linters like twigcs keep code more consistent and readable
-
acceptedUse ImageMagick with Drupal
Drupal requires the GD PHP extension, but many sites prefer ImageMagick for better performance, flexibility, and reliability. This choice affects image features, speed, and deployment in various hosting environments.
-
acceptedUse only one h1 on each page
Using one h1 on each page is best practice for accessibility and usability.
-
acceptedDo not use placeholder text in form fields
Placeholder text introduces significant usability and accessibility issues and should be avoided.
-
acceptedOrder content type form fields based on content priority
When content types have dedicated pages, matching the display order when possible makes edit forms easier to understand.
-
deprecatedStandardize the order of steps when building a Drupal site
When updating Drupal code and configuration in a given environment, it's useful to make sure all members of the team and all teams follow a consistent set of steps, in the same order. Having consistent steps across multiple projects will reduce onboarding for new team members.
-
acceptedUse Typed Entity to encapsulate business logic in dedicated classes
Wrapping the business logic for an entity using Typed Entity produces code that is easier to read, maintain, test, and discover.
-
acceptedLeverage view modes when rendering entities
Rendering entities using view modes have multiple benefits. These include better maintainability, faster initial development time, better performance, and hardened security.
-
acceptedUse identical cache backends on development environments
Using memory caches like Memcached or Redis in production but not in development environments can lead to bugs and confusion.
-
acceptedDo not add the Metatag field to the node form
The metatag field makes the node form slow and overly complex for editorial users.
-
acceptedUse Claro for the Drupal administration theme
Claro offers a modern, responsive, and accessible interface that showcases Drupal's capabilities from the outset.
-
acceptedUse Type Tray to improve editorial UX
Drupal's editorial experience in the "Add Content" page is confusing out of the box, especially when the content model's complexity increases.
-
acceptedUse Simple Add More to improve editorial experience
Drupal core by default outputs the maximum number of values (cardinality) as empty elements on entity forms, which usually represents a poor user-experience.
-
acceptedBreak composer install if patches don't apply
Allowing builds to succeed with failed patches can lead to malformed code or hidden errors.
-
acceptedUse local copies of patch files
When using cweagans/composer-patches, it is important that patch sources are consistent and do not change between builds.
-
acceptedStore Composer Patches configuration in composer.json
Validating a complete Composer configuration is important to ensuring build issues are caught early.
-
acceptedConfigure Composer Patches to Use `-p2` as `patchLevel` for Drupal core
Drupal's git repository has a different directory structure than projects built on Drupal. Default Composer Patches settings can cause Drupal patches to be silently misapplied.
-
acceptedAlways hide non-translatable fields on translation forms
When content translation is enabled, it's possible to decide which fields can be translated.
-
acceptedLock entity language on edit forms
Editors new to Drupal often try to translate content by changing the language on existing content, causing confusion for site visitors.
-
acceptedConsistently name entity fields
Adopting a consistent set of rules when naming entities in Drupal can reduce errors and improve maintainability.
-
deprecatedComposer patches configuration and best practices
Default
composer-patchessettings can lead to misapplied patches or hidden errors. Using a consistent configuration across projects will reduce errors and save time. -
acceptedUse PHPUnit for unit testing PHP code
-
acceptedBlock the Drupal user 1 account in production environments
The first user account in a Drupal site (often referred to as "administrator" or "user 1") is granted every permission automatically. If the account credentials are compromised, an attacker can easily inject JavaScript to attack site visitors and can likely execute arbitrary PHP code.
-
acceptedAlways use typehints in new PHP code
Following stricter typing where available can significantly reduce bugs, and simplify maintainability. This has been proven by several studies across different disciplines.
-
acceptedConfirm Drupal site configuration is always in a default state
Configuration should never be in an overridden state after configuration import(s) have been completed.
-
acceptedUse DDEV for local environments
The software development industry is continuing to move to containers both for production and local environments. It's clear that the bulk of new investment in local tooling is going towards container-focused solutions. While containers themselves add some complexity to local environments, they also reduce variance in development environments for teams with multiple developers.
-
acceptedUse strict types in PHP code
PHP's type coercion can cause logical errors within a program. For example, when a float is cast to an int, the decimal portion is lost. We aim to reduce these errors in our code, but they can easily slip through manual code review. Following stricter typing where available can significantly reduce bugs, as shown by Python's urllib3 type hinting case study.
-
acceptedStage File Proxy for static files
Lullabot often works on projects that have large numbers of static file assets in production, such as images or PDFs. Keeping a complete copy of those files for each environment is wasteful, since developers tend to only look at a small portion of a site locally. A solution is needed to reduce disk use and the time it takes to update an environment.
-
acceptedUse settings.php for environment overrides and local settings
When developing a Drupal website, additional modules and configuration are useful for local and development environments.