Templating Strategy

Current Approach: PHP Templates + Twig Migration

We use PHP templates with inline HTML, with an ongoing migration to Twig for reusable components and new pages.

What’s Been Done (June 2026)

CSS Utility Classes Added

70+ utility CSS classes added to public/assets/styles.css:

Inline Style Reduction

Twig Components Available

File Organization

src/views/
├── pages/              # Full page views (PHP templates, migrating to Twig)
│   ├── contract/
│   ├── invoice/
│   ├── quote/
│   ├── client/
│   ├── settings/
│   └── ...
├── partials/           # Layout components (header, footer)
├── templates/          # Twig templates
│   ├── layouts/        # Base layouts
│   └── components/     # Reusable Twig components
└── public/             # Public document templates (Twig)

Migration Strategy

Phase 1: CSS Cleanup (DONE)

Phase 2: List Pages to Twig (NEXT)

Phase 3: Detail Pages to Twig

Phase 4: Form Pages to Twig

Best Practices

  1. New pages use Twig: All new pages should use Twig templates
  2. Escape all output: htmlspecialchars() in PHP, `` in Twig (auto-escaped)
  3. Use CSS classes: No new inline styles — use utility classes or add new ones to styles.css
  4. Keep logic in controllers: PDO queries belong in controllers, not view templates
  5. Use Twig components: Reuse list-view.html.twig and document-filter.html.twig for list pages
  6. Document components: Add usage examples in comments