> loading /blog/laravel-api-patterns...
Laravel API Patterns for Production Apps
By First Data Team, Engineering & Product
Form requests, resources, policies, and queue boundaries we use on every backend engagement.
A Laravel API is only as maintainable as its boundaries. We treat controllers as HTTP adapters, not business logic containers, every write path goes through a Form Request and a dedicated action or service.
##Validation at the edge
Form Requests enforce authorization and validation before a controller method runs. Nested array rules use dot notation; custom messages map to translation keys for bilingual clients.
##Consistent JSON contracts
API Resources shape outbound data, never return Eloquent models directly. Pagination uses a standard envelope: success, message, data, meta.
##Authorization everywhere
Policies gate model actions; middleware handles route-level permissions. Element-level checks belong in resources and form requests, not scattered in controllers.
##Async by default for side effects
Emails, webhooks, and heavy transforms go to queued jobs with explicit tries, backoff, and failed() logging, the request cycle stays fast and predictable.