clqms-be/.serena/memories/clqms01-be/style_conventions.md

1.0 KiB

CLQMS backend is a PHP 8.1+ CodeIgniter 4 API-only project that follows PSR-12 spacing/brace rules and prefers short arrays. New PHP files should enable declare(strict_types=1) and use typed arguments/returns (nullable unions over doc-only hints). Controllers use ResponseTrait to emit { status, message, data } JSON responses; shared logic lives in app/Libraries/app/Traits. Guard clauses and single-purpose helpers keep methods ~40 lines; repeated flows are extracted. Database work uses Query Builder/Model methods, helper('utc'), and checkDbError() for manual queries. Multi-table writes wrap $this->db->transStart()/transComplete() with status checks. Lookups leverage App\\Libraries\\Lookups and JSON files in app/Libraries/Data/valuesets/. Routes stay in app/Config/Routes.php grouped by resource; filters like auth guard protected routes. Audits/logging use log_message with sanitized data. Tests live under tests/Feature and tests/Unit, use PHPUnit 10.5+ conventions, and expect status assertions per HTTP semantics.