dd_id_804b83e7f5
3. App Technical
Code Conventions
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_encodefor JSON responses and set content type.
TypeScript
- Prefer
constandreadonlywhere possible. - Avoid
any; use precise types orunknown. - 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
labeltags. - 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
flexorgridover manual positioning.