forked from ChurchCRM/CRM
-
Notifications
You must be signed in to change notification settings - Fork 0
Code Conventions Style Guide
Charles edited this page Jul 1, 2017
·
2 revisions
The API is built with Slim version 2.0
We are using Monolog for logging. In Standard pages we have $logger
var that can be used if the debug is enabled in the System Settings. In the Slim APIs you can use $this->Logger->
var.
- We use the AdminLTE theme to generate a consistent UX for our users. Before you make any UI changes please review the AdminLTE documentation for the best way to leverage the theme's built in JavaScript and CSS.
- AdminLTE contains many JavaScript Plugins (including JQuery and Bootstrap), so before adding any external components, please evaluate the plugins already in the project.
- We use editorconfig to normalize code styling.
- Not all code styles are supported for normalization within editorconfig, so please refer to the list below
- All files use LF (Unix) line endings. CI Tests will fail for any PR containing CRLF or CR line endings.
- All tabs are represented as spaces
- A single "tab" is expanded to 2 spaces
- A new line should follow the following clauses:
- else
- elseif
- while
- finally
- catch
- New lines should not follow class or scope definitions like "class", "public", or "private"
- All open braces should be on the same line as the control statement:
- Class definitions
- Method declarations
- if, else, elseif
- for, foreach
- while
- do
- switch
- try, catch, finally
- All close braces should be on their own line.
- A space should occur:
- Inside the parentheses in the following statements:
- if, elseif
- for, foreach
- while
- catch
- switch
- Before and after the following elements:
- Binary operators ( < > == )
- Ternary Operators ( $b ? $a : $b )
- String Concatenation Operator ' . '
- Key => Value Operator
- Assignment Operator ($b = 5)
- After
- Comma
- Semicolon
- Type-casts
- Short PHP Tag
- Before
- Close PHP Tag
- Inside the parentheses in the following statements:
- We don't use PHP short tags
- We do use <?= in place of <?php echo.