- We adhere to all PHP Framework Interop Group standards, particularly PSR-2 as a coding style guide. It's recommended to use a tool such as PHP_CodeSniffer or PHP Coding Standards Fixer to easily detect — and even fix — violations to the standard.
- Dependency management should be done with Composer.
- Code documentation should be done with phpDocumentor.
- Testing should be done with Codeception when a combination of acceptance, functional, API, and unit testing is necessary (such as for an app). Use phpUnit when only unit testing is necessary.
- Task running should be done with Grunt, which is becoming increasingly popular among PHP projects as an alternative to Phing.
- Code quality and analysis tools should be used if possible, such as:
In addition to PSR-2, we adhere to the following coding style rules:
-
Use
echo
shortcut syntax within HTML blocks. Variable should be surrounded by spaces and omit semicolons:<!-- Good --> <p><?= $var ?></p> <!-- Bad --> <p><?=$var?></p> <p><?= $var; ?></p>
-
Line up object operators (
->
):// Good $AnObject->foo() ->bar() ->baz(); // Good $AnObject ->foo( really, long, argument, names ) ->bar( really, long, argument, names ) ->baz( really, long, argument, names ); // Bad $AnObject->foo() ->bar() ->baz();