Laravel recently started using the PSR-2 style guide. PSR-2 is a coding style agreed upon by many PHP framework developers. It’s an extension of the original PSR-1, which basically has 3 main conventions.
- Classes are upper Camel case.
- Methods are lower Camel case.
- Constants are written in caps like VERSION_NUMBER.
PSR-2 expands this by using these standards
- Indents are 4 spaces instead of tabs.
- Keep line lengths at 80 characters. Soft limit of 120 characters.
- Use one blank line after a namespace declaration. Use a blank line after a group of declarations.
- Opening braces for classes MUST go on the next line. Closing brace must be on its own line.
- Opening braces for methods must go on the next line, and a separate line for the closing brace.
- Closures must have a space after the function keyword.
- Control structures, like IF, WHICH, FOR, and FOREACH must have one space before the condition parenthesis.
- The case keywords should be indented from the switch keyword.
- Keywords, like true, false, and null show be in lower case.