aboutsummaryrefslogtreecommitdiff
path: root/docs/adr/0002-attribute-based-route-declaration.md
blob: d1d4c799d2d3596e3cc04b69ea673f52362fd6d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# ADR 0002: Attribute-Based Route Declaration

- Status: Accepted
- Date: 2026-08-17

## Context

Routes need a home that does not grow linearly in a central composition root.

## Decision

Routes are declared with method-specific PHP attributes (`Get`, `Post`, `Put`,
`Patch`, `Delete`) on controller methods. A reflection-based `RouteLoader`
compiles them into `RouteDef` objects. `Middleware` is a repeatable attribute
valid on classes and methods.

Matching precedence is deterministic: literal segments sort before
`{parameter}` segments, so registration order is irrelevant.

## Consequences

- Adding a route touches only the controller.
- The loader must be covered by tests (reflection is where mistakes hide).
- Precedence is explicit rather than dependent on registration order.