This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:dev:all:wb-adaption [16.05.2015 09:26] – created Manuela v.d.Decken | en:dev:all:wb-adaption [13.06.2015 16:39] (current) – finished translation and removed the fixme-paragraph mrbaseman | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | FIXME **This page is not fully translated, yet. Please help completing | + | ====== General adjustment for Website Baker ====== |
+ | Since WebsiteBaker existed before the appearance of the PHP FIG standards a few adjustments to the standards are required, which are described below. Further adjustments to adhere are included in the chapters on the individual WB versions | ||
- | ====== Allgemeine Anpassung für WebsiteBaker ====== | + | < |
- | Da WebsiteBaker schon vor Erscheinen der PHP-FIG Standards existierte sind ein paar wenige Anpassungen der Standards erforderlich, | + | **Caution:** |
- | < | + | For all new Code the principle of electronic data processing, valid since the invention of the computer |
- | **Achtung:** | + | |
- | Für allen neuen Code gilt auch bei Websitebaker ab sofort die Grundregel der **E**lektronischen-**D**aten**V**erarbeitung, die seit der Erfindung des Computers Gültigkeit hat und bisher bei WB mit regelrecht penetranter Konsequenz missachtet wurde: | + | |
- | * **E**ingabe » **V**erarbeitung » **A**usgabe | ||
- | Diese 3 Bereiche müssen strikt getrennt werden und immer in der exakten Reihenfolge auftreten. Neue Module, die sich nicht an diese elementare Regel halten, werden in Zukunft nicht mehr in das Repository aufgenommen, | + | |
- | ===== PHP Dateiformatierung ===== | + | |
- | ==== Allgemein ==== | + | |
- | Für Dateien mit der Endung *.php, welche nur PHP Code beinhalten oder mit PHP Code enden, ist der schließende Tag **?>** nicht zugelassen. Er wird weder vom Webserver noch von PHP benötigt und das Weglassen verhindert, dass versehentlich Leerzeilen in die Antwort eingefügt und dadurch eventuell vorzeitig Header gesendet werden.\\ | + | These 3 areas must be strictly separated and always occur in the exact order. New modules that do not adhere to this basic rule are no longer included in future in the repository, or they are marked as '//**not compatible**//'.</blockquote> |
- | Beginnt eine Datei mit PHP Code, so ist zwingend das öffnende **<?php** Tag in der ersten Spalte der ersten Zeile der Datei einzusetzen. | + | ===== PHP File Formatting |
- | Textdateien (also nicht Binär-Dateien wie Bilder etc.) müssen grundsätzlich im UTF-8 Format ohne BOM (ByteOrderMark) abgespeichert werden.\\ | + | ==== General |
- | Dieser Punkt ist vor allem bei Benutzern von Windows-Umgebungen explizit zu beachten, da unter Unix/Linux in der Regel UTF-8 sowieso Systemstandard ist. | + | |
- | ==== Einrücken | + | |
- | Die Standardschrittweite des Tabulators ist auf 4 Leerzeichen einzustellen. Ein Einzug besteht grundsätzlich aus 4 Leerzeichen. Tabulatoren selbst sind an keiner Stelle erlaubt und sollten der Einfachheit halber vom Editor automatisch in jeweils 4 Leerzeichen umgewandelt werden. | + | |
- | ==== Maximale Zeilenlänge ==== | + | |
- | Die Zielzeilenlänge ist 80 Zeichen. Entwickler sollten jede Zeile ihres Codes unter 80 Zeichen halten, soweit das möglich und praktikabel ist. Trotzdem sind längere Zeilen in Ausnahmefällen erlaubt. Die maximale Länge einer PHP Codezeile sollte 130 Zeichen jedoch nicht überscheiten. | + | |
- | ==== Zeilenbegrenzung | + | |
- | Die Zeilenbegrenzung folgt der Unix Textdatei Konvention. Zeilen müssen mit einem einzelnen Zeilenvorschubzeichen(**LF**) enden. Zeilenvorschubzeichen werden durch eine ordinale 10, oder durch 0x0A (hexadezimal) dargestellt.\\ | + | |
- | :!: **Beachte: | + | |
- | ===== Namens-Konventionen | + | For files with the extension *.php which include only PHP code or end with PHP code, the closing tag **?>** is not allowed. It is not required by the web server nor by PHP and omitting it prevents from accidentally including blank lines which would may prematurely trigger that headers are sent.\\ |
+ | If a file starts with PHP code, the opening **<? | ||
+ | Particularly users of Windows environments have to be cautious about this, because usually for Unix / Linux UTF-8 is the system-wide standard anyway. | ||
+ | ==== Indentation ==== | ||
+ | The standard pitch of the tab should be set to 4 spaces. An indentation generally consists of 4 spaces. Tabs themselves are not allowed at any point and for convenience should be automatically converted by the editor each in 4 spaces. | ||
+ | ==== Maximum Line Length | ||
+ | The target line length is 80 characters. Developers should keep each line of their code below 80 characters, as far as is possible and practicable. Nevertheless, | ||
- | ==== Allgemeines | + | ==== Line termination |
+ | Line termination follows the Unix text file convention. Lines must end with a single linefeed (**LF**). Newline characters are represented by an ordinal 10, or 0x0A (hexadecimal).\\ | ||
+ | :!: **Note:** Do not use the carriage return (**CR** / 0x0D) as in the conventions of Apple or the combination of carriage return and line feed (**CR/LF** / 0x0D, 0x0A) as specified in the standard for Windows. | ||
- | WebsiteBaker übernimmt auch hier weitgehendst die PSR in einer an die Besonderheiten von WB angepassten Form. Die wichtigste Abweichung findet sich im Aufbau der Suchpfade für die Dateien. In späteren Versionen wird auch hier eine weitere Annäherung an PSR erfolgen. | + | ===== Naming conventions |
- | < | + | |
- | **Hinweis: | + | |
- | Die strikte Einhaltung dieser Konventionen ist zwingend erforderlich, | + | |
- | </ | + | |
- | ==== Klassen | + | |
- | Klassennamen müssen in **StudlyCaps** (auch // | + | |
- | ^Bezeichner ^ Status | | + | |
- | |smtp_mailer | [color=red]falsch[/ | + | |
- | |Smtp_Mailer | [color=red]falsch[/ | + | |
- | |SMTPmailer | [color=red]falsch[/ | + | |
- | |SmtpMailer | [color=green]richtig[/ | + | |
- | ==== Abstrakte Klassen und Interfaces | + | ==== General |
- | Generell folgen abstrakte Klassen und Interfaces der gleichen Konvention wie Klassen, mit einer zusätzlichen Regel: Die Namen von abstrakten Klassen und Interfaces sollten mit dem Term " | + | |
- | ==== Emulierte Namespaces | + | Website Baker largely adopts the PSR here as well, in a version slightly adapted to the specific requirements WB. The main difference is found in the structure of the search paths for the files. In later versions also here a further approximation to PSR will take place. |
- | In diesem Modus ist in Klassennamen zusätzlich der Unterstrich '_' | + | < |
+ | **Note:** | ||
+ | Strict compliance with these conventions is imperative so that there can be no homonyms of classes and functions / methods in different modules. The core is thus able to clearly determine the location of the class file based on the class name to reload them using the autoloader optimized on WB. An explicit inclusion of the class files via include () or require () is superfluous. | ||
+ | </ | ||
+ | ==== Classes | ||
+ | Class names must be declared | ||
+ | ^Identifier ^ Status | | ||
+ | |smtp_mailer | [color=red]wrong[/ | ||
+ | |Smtp_Mailer | [color=red]wrong[/ | ||
+ | |SMTPmailer | [color=red]wrong[/ | ||
+ | |SmtpMailer | [color=green]correct[/ | ||
- | Die Klassenbibliotheken von WebsiteBaker sind in mehrere Gruppen aufgeteilt:\\ | + | ==== Abstract classes and interfaces ==== |
- | **Klassen des Kerns**: sind im Verzeichnis | + | In general, abstract classes and interfaces follow the same conventions as classes, with an additional rule: The names of abstract classes and interfaces should end with the term "**Abstract**" or "**Interface**", and the term must not be preceded by an underscore. As an example |
- | **Klassen der Module**: Klassen der Module im jeweiligen Modulverzeichnis **'' | + | |
- | **Klassen des ACP**: (AdminControlPanel => ehem. Backend) sind im Verzeichnis | + | |
- | **Klassen der third-party libraries**: | + | |
- | ==== Dateinamen | + | ==== Emulated namespaces |
- | Soweit die vorgenannten Regeln für Klassennamen eingehalten wurden, ergeben sich die Dateinamen eindeutig aus den Klassennamen. Die Klasse **m_MyModul_PluginAbstract** findet sich demnach | + | In this mode in class names the underscore |
- | Für alle anderen Dateien sind nur alphanummerische Zeichen und der Bindestrich (**-**) gestattet. Leerzeichen sind völlig verboten.\\ | + | |
- | Jede Datei, die ausführbaren PHP Code enthält sollte mit der Endung **.php** enden und in UpperCamelCase-Schreibweise ausgeführt sein. | + | |
- | ==== Verzeichnise ==== | + | |
- | Zur Benennung von Verzeichnissen gelten die selben Grundlagen wie für Dateien. Es sind nur alphanummerische Zeichen sowie nur wenige Sonderzeichen des Standard 7-Bit-ASCII Bereiches < | + | |
- | ==== Funktionen und Methoden ==== | + | |
- | Funktions- und Methodennamen dürfen nur Alphanummerische Zeichen enthalten. Unterstriche sind nicht gestattet. Nummern sind in Funktionsnamen gestattet aber in den meisten Fällen nicht empfohlen. | + | The class libraries of WebsiteBaker are divided into several groups:\\ |
- | Wortreichtum wird generell befürwortet. Funktionsnamen sollten so wortreich wie möglich sein um deren Zweck und Verhalten möglichst genau zu erklären. | + | **The core classes**: reside in the directory **'' |
+ | **Classes of modules**: classes of modules in the appropriate module directory **'' | ||
+ | **Classes of ACP**: (AdminControlPanel => Former backend) are located in the directory **'' | ||
+ | **Classes of third-party libraries**: | ||
+ | ==== Filenames ==== | ||
+ | As far as the above-mentioned rules for class names have been complied with, the filename would clearly result from the class name. The class **m_MyModul_PluginAbstract** accordingly can be found in the file **'' | ||
+ | For all other files, only alphanumeric characters and the dash (**-**) are allowed. Spaces are strictly prohibited.\\ | ||
+ | Each file which contains executable PHP code should end with the extension **.php** and be carried out in UpperCamelCase. | ||
- | Funktionen oder Methoden sollen möglichst immer in //**lowerCamelCase**// | + | ==== Directories ==== |
+ | For naming directories the same basis as for files apply. Only alphanumeric characters and a few special characters of standard 7-bit ASCII range <128 (**[color=blue] ! # - . @ ~ [/color]**) are allowed. As with file names, spaces, and the underscore are prohibited. | ||
- | :!: **Achtung:** Es dürfen niemals doppelte Unterstriche als Prefix für Methoden-, Funktions- oder Variablennamen verwendet werden. Es besteht hier die Gefahr, dass es zu Überschneidungen mit aktuellen oder zukünftigen, PHP-eigenen | + | ==== Functions and Methods ==== |
+ | |||
+ | Function and method names may only contain alphanumeric characters. Underscores are not permitted. Numbers are however permitted in function names in most cases however not recommended. Verbosity is generally encouraged. Function names should be as verbose as possible to describe their purpose and behavior as precisely as possible. | ||
+ | |||
+ | Functions or methods have to be written whenever possible in // | ||
+ | |||
+ | :!: **Warning:** doulble underscores may never be used as a prefix for method, function, or variable names. There is the danger that it overlaps with current or future, PHP's intrinsic | ||