Skip to content

Instantly share code, notes, and snippets.

@sherakama
Last active April 25, 2020 20:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sherakama/d71f9a6070ed9264edf4 to your computer and use it in GitHub Desktop.
Save sherakama/d71f9a6070ed9264edf4 to your computer and use it in GitHub Desktop.
Stanford Web Services Drupal Development Standards

Drupal Development Standards

by Stanford Web Services
Version: 1.0.0
Date: October 30, 2015

This document is meant to be a comprehensive guide to web development standards for Stanford Web Services around Drupal web development. This document is our canonical source and guide.

Code Standards

Custom Module Development

Feature Development

Theme Development

  • Drupal 8 Twig coding standards.
  • Use our base core themes - Open Framework.
  • Use our core theme's framework Twitter Bootstrap.
  • Follow our Branding guidelines.
  • All themes must be responsive and work without JavaScript enabled.
  • Use semantic markup and css naming.
  • CSS files should live in a /css directory.
  • Javascript files should live in a /js directory.
  • Images should live in a /img directory.
  • Template files should live in a /templates directory.

Product (Distribution) Development

  • Create drush.make files for D7, or composer.json files for D8.
  • Never put content in to modules. Use our content server for sample content.
  • Write Behat tests.
  • Always provide an upgrade path between major versions.
  • Follow our best practices on how not to bork your website

General Practice

  • Always host under HTTPS.
  • Always use our Features, modules, themes, and approved contributed modules before creating your own.
  • Always contribute back to the community in the form of patches and pull requests.
  • Look for ways to create re-usable modules and features.

Documentation

  • Always document your code, modules, themes, and installation profiles.
  • Provide README.md files in all projects.
  • Explain how to install, configure, and use your contribution.
  • Provide troubleshooting steps or contact information for help.

Accessibility

Versioning

Version Control (Git/GitHub)

  • ALWAYS use version control.
  • When working on existing projects create feature branches. General practice suggests you name the feature branch after the ticket id.
  • When creating commit messages prefix the commit message with the ticket id you are working on. eg: "BASIC-123: My commit message".
  • When to branch, fork, or create a new GitHub organization.
  • Create a repository for each module, feature, or theme. Do not include whole sites in one repository.
  • Do not use git submodules.
  • Use Drupal version conventions to name your main branches.
  • When creating a git tag use GitHub's release system and follow Drupal version conventions.

Namespacing

  • Use PSR-4 namespacing.
  • Prefix with the Stanford namespace. Eg: field_stanford_ or \Stanford\Department\MyFeature\MyFeature.php.

Workflow

Open Source

  • We use open source daily and should contribute back when possible.
  • Leave GitHub repositories public unless otherwise directed.
  • Use open source software when possible.

Security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment