Skip to main content

Coding Style

This page captures the coding conventions already used by LogiDAV.

The canonical in-repo guide is CODING_STYLE.md at the project root, and this page mirrors the same rules for the MkDocs site.

Core Principles​

  • Prefer readable, maintainable code over clever shortcuts.
  • Keep changes narrow and consistent with the surrounding bundle.
  • Favor explicit dependencies and predictable side effects.
  • Treat cronjobs, queues, shipments, payments, and stock updates as high-risk flows and code defensively.

PHP and Formatting​

  • Target PHP 7.3.* compatibility.
  • Follow PSR-2 / PSR-12 style.
  • Use 4 spaces, no tabs, UTF-8, and Unix line endings.
  • Prefer short array syntax: [].
  • Keep imports tidy and remove unused imports.

The formatter rules come from .php-cs-fixer.php at the project root.

Symfony and Architecture​

  • Keep services stateless when possible.
  • Use constructor injection instead of container lookups in business logic.
  • Align namespaces with bundle structure.
  • Use role-based class names such as *Service, *Command, *Controller, and *Repository.
  • Prefer route annotations for controllers already covered by annotation imports.

Doctrine and Workflow Safety​

  • Keep query logic in repositories when practical.
  • Keep transactions short.
  • Avoid large in-memory result sets in batch jobs.
  • Be especially careful in workflows that mutate sales, refunds, shipments, and stock.

Tests and Documentation​

  • Mirror source namespaces under tests/.
  • End test classes with Test.
  • Add short PHPDoc to non-trivial methods, especially around integrations and custom behavior.
  • Update documentation when a production workflow changes.

Validation Commands​

php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php
composer phpstan
SYMFONY_DEPRECATIONS_HELPER=weak_vendors vendor/bin/simple-phpunit -c phpunit.xml.dist