-
Notifications
You must be signed in to change notification settings - Fork 1
Coding
When developing within the project of World Wide Importers, there is a need for certain formatting within the code.
Nesting
When nesting Sass or SCSS they need to be nested when possible. There is no limit of the max amount of nesting.
// Yey
.partent {
.child0 {
margin-top: 2em;
}
.child1 {
margin-bottom: 2em;
}
}
// Nah
.partent .child0 {
margin-top: 2em;
}
.parent .child1 {
margin-bottom: 2em;
}
Strings as CSS values
Specific CSS values (identifiers) such as initial
or sans-serif
require not to be quoted. Indeed, the declaration font-family: 'sans-serif'
will silently fail because CSS is expecting an identifier, not a quoted string. Because of this, we do not quote those values.
// Yey
$font-type: sans-serif;
// Nah
$font-type: 'sans-serif';
Zeros
Numbers should display leading zeros before a decimal value less than one. Never display trailing zeros.
// Yey
.foo {
padding: 2em;
opacity: 0.5;
}
// Nah
.foo {
padding: 2.0em;
opacity: .5;
}
Within the PHP code of World Wide Importers we need to follow certain conventions. In the list below you'll find all our 'rules' we apply.
Functions
The manner of making a function within this repository.
// Yey
function functionName(param) {
# code
}
// Nah
function functionName(param)
{
# code
}
Echo's and print
When data needs to be displayed in the view of the page use print();
. The use of any kind of echo "";
is prohibited. Never use one of these in a controller!
// Yey
print("Hello World");
// Nah
echo "Hello World";
// Nope, nope
echo("Hello World");
Try, catch
When using a try
, catch
construction you'l need to catch the Exception
as $e
. The exception needs to be stored with the setAlert()
function. See as follows.
// Yey
try {
# some action
} catch(Exception $e) {
setAlert("Error with something", "info", $e);
# possible some header
}
// Nah
try {
# some action
} catch(Exception $exception) {
print($exception);
# other code
}
General
Is the made function used more than two times? Then place it in src/inc/functions.php
.
When making/modifying a .php
file always include src/inc/config.php
. This will ensure you have access to functions and static variables listed in src/inc/functions.php
.
Do this by adding the following line at the top of your controller file:
require('inc/config.php');