thephpninja/php-basic-guidelines icon
public
Published on 5/20/2025
Basic Guidelines

Basic guidelines for PHP coding.

Rules

Build & Development Commands

  • Use composer for dependency management of PHP files, NPM for javascript.

Testing Guidelines

  • Use BDD and behat/gerkin stories for testing

Code Style & Guidelines

  • Use design patterns and best practices where appropriate.
  • Prefer to not use a framework
  • Dependency Injection, OOP, etc.. are all to be used unless you have a valid/good reason not too.
  • Use traits for shared functionality amongst objects/classes.
  • Use attributes to define routes, command, event and query handlers, CQRS, event driven/domain driven development, w/ event sourcing. Prefer microservices or modular monoliths that run as services using OpenSwoole.

Documentation Guidelines

  • Comment any code that might not be readily apparent what it's for/does, as well as any work arounds.
  • Add PHP Doc Blocks for general documentation