User Tools

Site Tools


en:dev:all:psr

This is an old revision of the document!


FIXME This page is not fully translated, yet. Please help completing the translation
(remove this paragraph once the translation is finished)

Coding Standards

Official Standards

We did not reinvent the most basic standards for Website Baker and arbitrarily define some rules, but we use basically the same set of rules as many other notable projects and large frameworks (see PHP-FIG Referenzliste).
The basic standards for Website Baker are the standards PSR-0 / PSR-1 / PSR-2 and PSR-4 of the PHP Framework Interop Group.
Some might feel uncomfortable with the quite strict wording using the expressions MUST! or MUST NOT! etc. However, these terms are taken exactly as they are from the original PSRs which in turn striclty stick to RFC 2119 and should therefore be understood exactly in this sense.
The most important keywords defined in RFC2119 are:

keyword explanation
MUST / REQUIRED / SHALL This means that the definition is an absolute requirement of the specification.
MUST NOT / SHALL NOT These phrases mean that the definition is an absolute prohibition of the specification.
SHOULD / RECOMMENDED This is also a very strong requirement/prohibition. However, there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.
SHOULD NOT / NOT RECOMMENDED
MAY / OPTIONAL This states an item which is truly optional.
  • Autoloading Standard (PSR-0) - This standard aims to provide a standardized file format, as well as class name and namespace conventions that enable plug and play code.
  • Basic Coding Standard (PSR-1) - This standard helps to achieve the highest possible degree of compatibility of PHP code contributed from different sources.
  • Coding Style Guide (PSR-2) This provides instructions that ensure that PHP code always has a standardized visual appearance.
  • Improved Autoloading (PSR-4) -A more modern interpretation autoloading, which reflects the continued progress in the ecosystem.
  • WebsiteBaker-Adaption - General adaptation of PSR standards to specific conditions of Website Baker.

Basic rules for programming in the WB-environment

With every subsequent release of WebsiteBaker, the programming style evolves continually away from the previous 'anarchic' style, widely used for almost 10 years, towards to a more modular, but also forcibly bound to strict programming interfaces manner. This requires a consistent rethinking especially for addon programmers.
At present, i.e. before 2.8.4, compliance with many regulations is still voluntary, in the 2.8.4 much is already deprecated, and later on many of the specifications of 2.8.4 will be mandatory. All this sounds very restrictive to many, but this is gladly accepted, since precisely these limitations will eventually ensure a stable modularity, flexibility and interchangeability for stable, reusability and mainly maintainability of code.

Allgemeine Regeln für Addons

.. die eigentlich so, unabhängig von WB, in jedem halbwegs professionellen Projekt gelten sollten und Grundlage jeder ernsthaften Programmierer-Ausbildung sind.

Addons…

  1. … dürfen weder den Core noch andere Addons triggern, sondern werden grundsätzlich vom steuernden Core getriggert
  2. … dürfen den Ablauf des Gesamtsystems nicht stören
  3. … ist im Normalfall keine direkte Verbindung zur Außenwelt gestattet
  4. … dürfen niemals schreibend auf Datenbereiche anderer Addons oder des Core zugreifen
  5. … dürfen niemals den Code anderer Addons oder des Core ändern (gilt auch für Installation und Upgrade)
  6. … dürfen ausschließlich über den Responder des Core Daten zum Browser etc. senden
  7. … dürfen keine globalen Variablen oder globalen Konstanten definieren.

für spätere Versionen (ab 2.9) werden noch weitere Einschränkungen kommen. Siehe die jeweiligen Abschnitte dieser Dokumentation.

en/dev/all/psr.1432569816.txt.gz · Last modified: 03.06.2015 15:55 (external edit)