mtownsend/response-xml
Return XML from your Laravel API as easily as JSON. This package adds a fluent xml() response helper that converts Eloquent models, collections, arrays, and paginators into clean, customizable XML, with support for custom root nodes, headers, and encoding — no manual string building required.
response()->xml($data, $status, $headers, $xmlRoot) a first-class citizen alongside response()->json().XmlResponse and Laravel's response factory, this is a "buy" only in the trivial sense. The PM decision is really "do we write our own 40-line macro or accept a dependency?" That should be decided deliberately, not by default.Adopt when all of the following hold:
Response::macro('xml', ...) is a comparable — arguably preferable — cost.Look elsewhere when:
response()->make($xml, 200, ['Content-Type' => 'application/xml']) covers 90% of the need.Risk notes for the record: license is clean (MIT) and the API is small enough that vendor-and-own is cheap. The 39.5 opportunity score and zero dependents are a maintenance signal, not a quality signal — the code is simple, but you are likely the only one who will notice a break.
For executives (one paragraph): A small, MIT-licensed helper that lets our Laravel application return XML as easily as it returns JSON. It is the cheapest way to satisfy any partner or compliance requirement that still speaks XML, and it costs us effectively nothing to adopt. The strategic caveat: it is a low-adoption, single-maintainer library, so we should treat it as convenience code we could absorb into our own codebase in an afternoon rather than a long-term vendor dependency. Recommendation: approve for bounded, outbound XML endpoints; do not build contractual SLAs on it without a vendor-and-own plan.
For engineering (the ask):
mtownsend/response-xml adds an xml() response macro to Laravel, wrapping Symfony's XmlResponse. Install, publish config if needed, return arrays from controllers.App\Support and drop the dependency.Decision requested: approve adoption for scoped, read-only XML output; defer any strategic XML API commitment until the spike reports back on shape coverage and vendor-vs-depend trade-off.
How can I help you explore Laravel packages today?