Configuring Custom URI Templates and Paths
Configuring Custom URI Templates and Paths
~13 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
So far, API Platform has derived ALL paths AUTOMATICALLY from the class name (Project → /api/projects). The uriTemplate parameter allows deviating from that ON PURPOSE.
uriTemplate at the resource level
#[ApiResource(
uriTemplate: '/ventures',
operations: [
new GetCollection(),
new Get(),
new Post(),
new Put(),
new Patch(),
new Delete(),
]
)]
From now on the endpoint is /api/ventures instead of /api/projects – the PHP class, the entity name, and the database table remain COMPLETELY untouched, ONLY the publicly visible API path changes.
Achtung: For OUR project we stick with the AUTOMATICALLY derived paths (/api/projects, /api/tags) – this example is PURELY for demonstration and is NOT carried forward permanently, to avoid confusion in later chapters.
uriTemplate per individual operation
Instead of the ENTIRE resource, a SINGLE operation can also be renamed on its own – handy for making ONE endpoint more descriptive without changing all the others.
new GetCollection(uriTemplate: '/projects/list'),Now GET /api/projects/list exists IN ADDITION to the rest of the UNCHANGED default paths of the other operations – a pattern that becomes important LATER (chapter 61) for entirely CUSTOM, additional actions like /projects/{id}/archive.
Checking the actual path
docker compose exec php bin/console debug:router | grep -i projectEXACTLY as shown in chapter 9, debug:router lists ALL actually registered routes – the MOST RELIABLE way to check which path is REALLY active, instead of relying on the source code alone.
Tipp: uriTemplate ALSO supports explicit placeholders like {id} – that will ONLY really be needed in block 5 (nested resources like /api/projects/{projectId}/tasks).