Clean Framework · DOCUMENTATION
Put a use case in a service
Put a use case in a service
Steps
Accept repository interfaces in a constructor and return presentation/domain values. Controllers translate HTTP; services own orchestration and transactions for mutations.
// BrowseReadingList member; the repository and ReadingItem type are imported in its source.
public function find(string $slug): ?array
{
return $this->repository->findBySlug($slug)?->toArray();
}Read the service source before copying this excerpt. Null means absent data; the controller decides the HTTP 404.
Verify
Inject a deterministic repository and test data mapping independently of HTTP. See Application walkthrough.
Editorial provenance
Source: resources/guides/service.md. Source SHA-256: 6f74fe33fd5fec0c301c402f28572e28e72e6f05f6855510f48ec612ce812826.
Knowledge-base application source; editorial checkpoint 2026-10-20. See candidate status and adoption boundary.