Conventions

More automation, less configuration : the key is convention

Conventions are useful. Not only they allow the code to be clean and consistent, but they also allow a lot of automation.

Diem follows all symfony conventions, and adds some.

Syntaxes

When naming something in the code ( a model, a module, a variable, a method... ), there are three ways to do it:

Underscored

Lowercase, words separated by an underscore.

this_is_an_underscored_word

When use the underscore syntax ?

  • database table names
  • database field names
  • php functions ( typically helper functions )
  • array keys ( like dependency injection service parameters )

Camelized

Uppercased first letter, words separated by an uppercased letter.

ThisIsAnUppercasedWord

When use the camelized syntax ?

  • models class name

Modulized

Lowercased first letter, words separated by an uppercased letter.

thisIsAModulizedWord

When use the modulized syntax ?

  • methods
  • variables
  • modules
  • templates
  • non model class names

Conversion

Diem provides methods to transform a string from a syntax to another one.

dmString::underscore($string) // transform $string to underscored syntax
dmString::camelize($string)   // transform $string to camelized syntax  
dmString::modulize($string)   // transform $string to modulized syntax  

Coding standarts

The symfony coding stadarts are applied and recommended, without any addition.

Learn about symfony coding standarts

Questions and Feedback

If you need support or have a technical question, you can

  • Post to the google group
  • Come and chat on the #diem IRC channel on freenode