Coding standards

The Drupal Coding Standards apply to code within Drupal and its contributed modules.

Coding standards

The Drupal Coding Standards apply to code within Drupal and its contributed modules.

API documentation and comment standards

This page covers:

API Documentation Samples

This page is a work in progress. See issue

CSS

CSS coding standards and best practices.

JavaScript

JavaScript coding standards and best practices for Drupal.

Markdown coding standards

This is currently being discussed in [#2191525].

Namespaces

PHP 5.3 introduces namespaces to the language. This page documents how namespaces should be referenced within Drupal and it assumes that

Naming standards for Services and extending Symfony

Manipulating the Request object:

Object-oriented code

Drupal follows common PHP conventions for object-oriented code, and established industry best practices. As always, though, there are

PHP Exceptions

Basic conventions

PSR-4 namespaces and autoloading in Drupal 8

Summary

SQL coding conventions

Don't use Reserved Words

Avoid "SELECT * FROM ..."

Using SELECT * FROM {node} queries in versions prior to Drupal 7 can introduce a potential security issue by causing Drupal's Node Access

List of SQL reserved words

The list below represents a combination of the following sources of SQL reserved words:

Temporary placeholders and delimiters

Temporary place-holders and delimiters

Twig coding standards

The majority of Twig coding standards can be found on the Twig website along with Twig documentation. Items on this page (below) are useful

Use Drupal Unicode functions for strings

If you are writing a module or theme, consider that it may be used on web sites around the world, some of which use languages whose

Write E_ALL compliant code

Adjusting the error reporting level

Drupal SimpleTest coding standards

You should follow these conventions when writing a test.

Drupal Markup Style Guide

The Drupal Markup Style Guide is a document in progress on how to:

Configuration file coding standards

This page covers:

Composer package naming conventions

This is WIP documentation for [#2401519].

Guide maintainers