Skip to content

Coding Style

Sébastien Villemain edited this page Nov 9, 2018 · 12 revisions

A few words about the style and rules of development.

Rather than writing hundreds of lines on the standards, try to just soak in what already exists. Readability is important, but not doing too much is even more important.

PHP Standards

Use the PHP Standards Recommendations.

Beginning

PSR-4: Autoloader.

As of 2014-10-21 PSR-0 has been marked as deprecated. PSR-4 is now recommended as an alternative.

Next

PSR-1: Basic Coding Standard.

Note 4.2. Properties : MUST be in camelCase.

But also

PSR-2: Coding Style Guide.

Specific to the project

Because it's good to do differently. 😁

PHP: things to know

  1. Do not use error control operator: the at @ sign. Never use it.
  2. Do not use print(). echo() does it lighter.
  3. Do not use Global. Global variables come with some special overhead.
  4. Do not use double quoted syntax for Strings: the " sign. 99% of time, it is necessary to use the single quotation mark '.
  5. Do not use Superglobals. Use only CoreRequest.

Various little things

  1. If you create a new folder, also create an index.html file.

Rule for the database

  1. Put everything in lowercase
  2. Separate words with the underscore
  3. Put the names of the tables in the plural
  4. Avoid abbreviations
  5. Use the UTF-8 charset
  6. Use SQL constraints (FOREIGN KEY, REFERENCES, ...)
Clone this wiki locally