cardinalby/content-disposition
A small PHP library for parsing and generating HTTP Content-Disposition headers, including attachment/inline types, quoted filenames, and RFC 5987/6266 filename* encoding for safe, browser-compatible file downloads.
header('Content-Disposition: attachment; filename=...') string a developer improvises.download, file (1).pdf, or mojibake. RFC 6266 / RFC 5987 filename* handling with a quoted ASCII fallback is the specific capability that decides whether you can promise "your export keeps its original name" to non-English markets without a support-ticket tail.Content-Disposition value is a header-injection control, and it belongs on the secure-coding checklist next to output escaping. A vetted implementation makes that control auditable rather than tribal knowledge.Content-Disposition to learn the filename. That is a distinct use case from generating headers and is the main reason to want a parser rather than a formatter.Adopt it, or at minimum adopt its behaviour, when:
Content-Disposition from upstream responses or multipart payloads, not just emit it.Look elsewhere when:
symfony/http-foundation, Guzzle, or laminas-http; this package does not model requests, responses, or streams.response()->download() / streamDownload() plus Symfony's HeaderUtils::makeDisposition() covers the common path; verify whether your actual gap is UTF-8 filename* fallbacks and parsing before adding a dependency with no maintenance signal.To executives: This is a small, low-cost correctness fix for a customer-visible quality issue — file downloads that arrive with mangled or generic names, most visibly for non-English users. It carries no infrastructure cost and no vendor contract, and integration is measured in hours. The trade-off to acknowledge plainly: it is a micro-utility with negligible adoption and no recent releases, so we treat it as a component we may own rather than a strategic dependency. Low risk, low cost, modest but real upside in support-ticket reduction and international polish.
To engineering: One job — build and parse Content-Disposition values correctly, including RFC 5987 filename* with an ASCII fallback and safe quoting against header injection. No Laravel wiring, no config, no runtime overhead. Proposed use: wrap it behind a narrow interface in our own code so the dependency is one file to replace, pin the version, add characterization tests for the browsers and languages we actually support, and keep the MIT-licensed source in mind as a fallback if maintenance stalls. Do not extend it into request/response or upload handling — that is out of scope for this library and stays with the framework.
How can I help you explore Laravel packages today?