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.

Grundsätzliche Regeln zur Programmierung im WB-Umfeld

Mit jeder weiteren Version von WebsiteBaker entfernt sich der Programmierstil immer weiter vom bisherigen, seit fast 10 Jahren gewohnten, 'anarchischen' Stil, hin zu einer immer modulareren, jedoch zwangsweise auch an strenge Schnittstellen gebundenen Programmierweise. Das wird vor allem von Addon-Programmierern ein konsequentes Umdenken erfordern.
Derzeit, also bis zur 2.8.4 ist die Einhaltung vieler Regeln noch freiwillig, ab 2.8.4 wird vieles bereits deprecated und ab 2.9 werden viele der Vorgaben zwingend sein. Das alles hört sich für viele sehr einschränkend an, was aber gerne in Kauf genommen wird, da genau diese Einschränkungen letztendlich für eine stabile Modularität, für stabile Flexibilität und für Austauschbarkeit, Wiederverwendbarkeit und vor allem Wartungsfreundlichkeit von Code sorgen werden.

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.1432566826.txt.gz · Last modified: 03.06.2015 15:55 (external edit)