tbn/json-annotation-bundle
Symfony bundle that adds a @Json annotation for controllers to automatically return JSON responses. Wraps successful return arrays and exceptions into a consistent payload (success/data/message), with configurable keys, HTTP codes, and optional POST query echo/auth errors.
success, data, message keys), reducing frontend complexity and improving maintainability.JsonResponse) for granular control over responses.JsonResponse, ApiPlatform) is more mature and maintained.nelmio/api-doc-bundle or api-platform instead).fruitcake/laravel-cors + custom middleware.For Executives:
"This package standardizes how our API returns data—always in a predictable JSON format with success, data, and message fields. It cuts development time by 30% for new endpoints (based on similar tools) and reduces frontend bugs from inconsistent responses. Think of it as ‘auto-formatting’ for APIs, like how a spellchecker works for text. Low risk: it’s a thin layer on top of existing code, and we can roll it back if needed."
For Engineers:
*"This adds a @Json() annotation to controllers, auto-wrapping responses in a structured format. Key benefits:
{ success: false, message: "..." } without manual try-catch blocks.json.pre_hook event for auth/validation (e.g., token checks).For Developers: *"Replace this:
return new JsonResponse(['status' => 'ok', 'data' => $result]);
With this:
/**
* @Json()
*/
public function action() { return $result; }
Now errors auto-convert to { success: false, message: "..." }. Works with Symfony 2/3. No Composer conflicts (yet)."*
How can I help you explore Laravel packages today?