Draconai Documentation

dd_id_804b83e7f5
3. App Technical

Code Conventions

Table of Contents

Overview

  • Keep changes focused and minimal.
  • Prefer explicitness over cleverness.
  • Match existing patterns in each folder.

PHP

  • Use declare(strict_types=1); at the top of PHP files.
  • Prefer typed parameters and return types.
  • Use early returns for guard clauses.
  • Keep controller logic thin; move heavy logic to helpers/services.
  • Use json_encode for JSON responses and set content type.

TypeScript

  • Prefer const and readonly where possible.
  • Avoid any; use precise types or unknown.
  • Keep components and utilities in small, focused modules.
  • Use consistent naming for events and handlers (e.g., handleSubmit).

HTML

  • Use semantic elements (header, nav, main, section, footer).
  • Keep forms accessible with proper label tags.
  • Avoid inline styles unless localized to a single page.

Twig

  • Keep templates lean; avoid heavy logic in views.
  • Use shared layouts and pass data from controllers.
  • Prefer path() for route URLs.

CSS

  • Use CSS variables for theme colors when introducing new styles.
  • Keep selectors simple and scoped to the page when possible.
  • Prefer layout with flex or grid over manual positioning.