Jump to the navigation menu

Custom coding standards and conventions

Open-source projects like Drupal and Symfony have their own published coding standards and conventions.

For example, from Symfony's coding standards:

  • Prefix all abstract classes with Abstract except PHPUnit *TestCase.
  • Suffix interfaces with Interface;
  • Suffix traits with Trait;

And from Drupal's:

  • Use an indent of 2 spaces, with no tabs.
  • Lines should have no trailing whitespace at the end.
  • Variables should be named using lowercase, and words should be separated either with uppercase characters (example: $lowerCamelCase) or with an underscore (example: $snake_case). Be consistent; do not mix camelCase and snake_case variable naming inside a file.

But what about within custom applications?

Do you have your own agreed coding standards and conventions to keep the code consistent?

Do you explicitly follow the published coding standards, customise them, or follow something else?

Here's the thing

Do you know where to put new custom modules, how to name them and what conventions to follow when writing code?

Do you know where to add a new stylesheet to your theme?

If not, or it's implied, it's worth writing it down and being explicit - either within your project's or company's documentation or publicly.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.