BenMakesGames/PoppySeedPets

controllers should use bespoke request DTOs instead of the `Request` service

Open

#18 opened on Apr 5, 2025

 (0 comments) (0 reactions) (0 assignees)PHP (6 forks)auto 404
good first issuetech debt

Repository metrics

Stars
 (14 stars)
PR merge metrics
 (PR metrics pending)

Description

Symfony added this feature a bit ago: https://symfony.com/blog/new-in-symfony-6-3-mapping-request-data-to-typed-objects

the LogInController uses it, but few other endpoints do. upgrade all controllers that handle requests to use them.

other notes:

  • if you find a controller that really feels like "nah, it should keep using Request", add a comment explaining why Request is being used instead of a request DTO
  • request DTOs must live in the same file as the controller that uses them
    • do not fall for the trap of "false sameness" - 99%+ of request DTOs have no business being shared between multiple endpoints

it's totally legit to upgrade just one endpoint or a small group of endpoints in a PR; this issue will be closed when no controllers remain which are using Request.

Contributor guide