Junior — Middle
Can you name the main PSR standards used in PHP development?
sobes.tech AI
Answer from AI
PSR (PHP Standards Recommendations) is a set of standards that help unify PHP code and improve its quality. The main standards commonly used in PHP development:
- PSR-1 — basic coding standards (e.g., class, method, and constant naming rules).
- PSR-2 — coding style guide concerning code formatting (indents, spaces, line breaks).
- PSR-4 — autoloading classes based on namespaces and file structure.
- PSR-7 — interfaces for HTTP messages (requests, responses).
- PSR-12 — an extension of PSR-2 with more detailed formatting rules.
Using these standards facilitates collaboration, makes code more readable, and compatible with popular libraries and frameworks.