Skip to content

Latest commit

 

History

History
77 lines (67 loc) · 2.4 KB

php.md

File metadata and controls

77 lines (67 loc) · 2.4 KB

PHP

  1. 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.
  2. Dependency management should be done with Composer.
  3. Code documentation should be done with phpDocumentor.
  4. 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.
  5. Task running should be done with Grunt, which is becoming increasingly popular among PHP projects as an alternative to Phing.
  6. Code quality and analysis tools should be used if possible, such as:

Coding Style Guide

In addition to PSR-2, we adhere to the following coding style rules:

  1. 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>
  2. 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();