"The idea behind the group is for project representatives to talk about the commonalities between our projects and find ways we can work together" - FIG FAQ
PSRs can be in the following states: Accepted, Review, Draft or Deprecated.
PSR-1: Basic Coding Standard
PSR-1 is an accepted recommendation and outlines a basic standard recommendation for how code should be written.
- It outlines naming convetions for classes, methods and constants.
- It makes adopting PSR-0 or PSR-4 recommendations a requirement.
- It indicates which PHP tags to use:
- It specifies what file encoding to use (UTF8).
- It also states that files should either declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or execute logic with side effects and not define symbols, but do both.
The fully qualified class name should match the following requirement:
- It MUST contain a top level vendor namespace (E.g.:
- It MAY contain one or more sub-namespaces (E.g.:
- It MUST contain an ending class name (E.g.:
Thus the final class name would be
Alphabet\Google\AdWord\KeywordPlanner. The fully qualified class name should also translate into a meaningful file path therefore
Alphabet\Google\AdWord\KeywordPlanner would be located in
Starting with PHP 5.3.0, a custom autoloader function can be defined to load files based on the path and filename pattern that you define.
Replacing the location ('classes/') and filename extension ('.class.php') with values that apply to your structure.
Regenerate the autoloader file
Now in your code you can do the following:
PSR-8: Huggable Interface
The draft outlines how to define an interface to make an object
Excert from the code outline: