Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Suitmedia PHP Coding Style

Edwin Lunando
September 28, 2014

Suitmedia PHP Coding Style

The PHP coding guideline for Suitmedia developer

Edwin Lunando

September 28, 2014
Tweet

More Decks by Edwin Lunando

Other Decks in Technology

Transcript

  1. Why?
    Everyone can easily read your codes just
    like reading their own codes

    View full-size slide

  2. Spaces is Better than Tabs
    4 spaces per indent
    All Editors have the same indent width
    Prettier code on Git

    View full-size slide

  3. No ?> In The End of File
    Only for file with all PHP codes
    Avoid additional new lines in generated document

    View full-size slide

  4. One Statement Per Line
    Easier to see changes with side-by-side diff

    View full-size slide

  5. Multiple Line Argument Lists
    One argument per line
    Use when have long argument lists

    View full-size slide

  6. Position of Opening and
    Closing Braces
    Class and Function declaration in new line
    Control Structures in the same line

    View full-size slide

  7. Explicit Declaration of
    Visibility
    public or protected or private or abstract or
    static or final

    View full-size slide

  8. Camel Case for Method
    wowSuchMethod, muchCamel, soCase

    View full-size slide

  9. Friendly Variable Names
    With Underscore
    Avoid $j, $i, $asd, $abc, $temp
    Use $join_table, $counter_product, $temp_collection

    View full-size slide

  10. Thank You
    source: www.php-fig.org

    View full-size slide