fileeye/mimemap
A PHP library for mapping MIME types to file extensions and back, using Apache and custom MIME data. Useful for file type detection, extension lookup, and consistent MIME handling in PHP or Laravel projects.
.docx → application/vnd.openxmlformats-officedocument.wordprocessingml.document, and back). It looks like a 20-line lookup table and is not: IANA registers ~1,600 media types, hundreds share extensions, extensions are case-insensitive, and Content-Type fields carry parameters (; charset=utf-8) that break naive string comparisons. This package is a buy decision that removes a recurring bug class for near-zero cost.Content-Disposition filenames on download (extension derived from the stored MIME type rather than trusting the client), server-side extension normalization on upload, "download as" / format-conversion pickers, attachment handling in outbound email, and media-library filtering by type family.mime.types, freedesktop) means "keep the MIME table current" becomes a scheduled CLI job rather than a manual PR. That is a real, quantifiable reduction in long-term ownership cost.finfo/magic-byte sniffing for actual content inspection) is an architecture decision worth making explicitly rather than by accident.Adopt when:
Look elsewhere when:
finfo/fileinfo or a scanning service, and be explicit with stakeholders that it is not a malware or spoofing defense on its own.Risk notes to weigh: low adoption means limited community scrutiny; repository metadata is unverified, which is a supply-chain concern worth a manual audit before pinning; and pin an exact version with a committed lockfile — do not float on ^.
To executives: This is a small, low-cost component that fixes a category of customer-visible defects — files that download with the wrong type, attachments that open incorrectly, uploads rejected for the wrong reason. It replaces hand-maintained lookup tables that silently rot with a mapping that can be refreshed from authoritative registries. The investment is measured in hours, the ongoing cost is a scheduled job, and the failure it prevents shows up in support tickets and trust. The one decision requiring their input is license policy.
To engineering: Don't hand-roll MIME mapping — the long tail and Content-Type parameter parsing will eat the sprint and keep eating it. This library gives bidirectional lookup plus regeneration from IANA/Apache/freedesktop sources. Wrap it behind a single internal interface (MimeResolver) so the dependency is swappable and testable, and pair it with finfo for actual content sniffing — this handles the label, not the bytes. Pin the version, vendor the lockfile, and treat the LGPL-3.0 license as a checkbox to clear with legal before we build on it.
How can I help you explore Laravel packages today?