quonain/smart-response
SmartResponse is a Laravel package that returns JSON API responses or Blade/Inertia views from the same controller method, auto-detecting request type (Accept header, /api routes, bearer tokens). Includes pagination, response shortcuts, macros, caching, and meta enrichment.
if ($request->wantsJson())) or write separate methods for API vs. web responses, cutting development time by ~30% for new endpoints.Admin/UserController) serving both API and Blade views.ContentController) with optional API enrichment (e.g., metadata, pagination).Adopt When:
Look Elsewhere If:
/api/* or Accept headers)."SmartResponse lets our Laravel team write one controller method instead of two—saving development time and reducing bugs*—while supporting both web and API clients seamlessly. For example, our admin dashboard can now serve Blade views to users and JSON to mobile apps from the same codebase. It’s a low-risk, high-reward upgrade that aligns with our goal of [faster iteration/multi-channel support]."*
Key Outcomes:
"This package automates response handling in Laravel by detecting whether a request expects JSON (API) or HTML (web) and returning the appropriate format—no more if ($request->wantsJson()) boilerplate. It also includes helpers for pagination, API meta-data, and rate limiting, which we’d otherwise have to build or maintain separately.
Why It’s Worth Trying:
Proposal:
Risk Mitigation:
Accept headers, custom route patterns).How can I help you explore Laravel packages today?