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.
Architecture fit. fileeye/mimemap is a standalone, stateless PHP utility library (Composer/PSR-4, no service provider, no facade, no framework coupling). It does not "integrate" with Laravel so much as sit behind it. That is actually the favorable property for us: it is a pure function over a data table — MIME ⇄ extension — with no I/O at request time beyond loading its mapping files. Architecturally it belongs in the infrastructure layer behind an internal interface (e.g. MimeResolver), never called directly from controllers or models.
Capability overlap is the central finding. Laravel already ships two MIT-licensed MIME facilities: symfony/mime (used for mail attachment handling) and league/mime-type-detection (pulled in by Flysystem, backs Storage::mimeType()), plus ext-fileinfo/libmagic for content sniffing. The marginal capability mimemap adds is therefore narrow: (a) high-fidelity parity with Apache/nginx mime.types, (b) reliable reverse lookup (extension → MIME), and (c) user-supplied custom mapping overlays (YAML) for long-tail formats. That third item is the real business case — CAD, geospatial, medical imaging, legacy Office/macro variants — where libmagic returns application/octet-stream and our download headers end up wrong.
Technical risk.
Content-Type on customer files. That is a regression-test obligation, not an ops footnote.Key questions.
application/octet-stream or a wrong type? Quantify the pain before adopting.Content-Type headers match the fronting web server / CDN, or only be internally consistent?ext-yaml? pure-PHP parser?) does it require, and do they match our runtime matrix?Stack fit. Low-friction on paper: composer require fileeye/mimemap, no framework bindings to wire, no config publishing required beyond pointing at our custom map path. Primary compatibility checks are PHP version constraint, transitive dependency conflicts, and whether the YAML mapping layer pulls an extension we do not run in production.
Migration path — adapter first, never a big-bang swap.
MimeResolver contract with mimeForExtension(), extensionsForMime(), and mimeForFile().FrameworkMimeResolver implementation using league/mime-type-detection + symfony/mime (today's behavior), bound as the default.MimeMapResolver implementation and bind it via a feature flag / config toggle.Compatibility and acceptance criteria. The migration is only justified if it is measurably better. Build a fixture corpus of 200–500 real anonymized customer files, run both resolvers, and diff. Accept the package only if it reduces unresolved/incorrect MIME assignments by a material margin and introduces zero regressions on the top 20 extensions. If the diff is noise, stop — the LGPL and bus-factor costs are not worth parity.
Sequencing.
Recommendation framing. Adopt narrowly, behind an interface, as a mapping consistency layer — not as a replacement for content detection. Do not make it a platform-wide dependency. If legal blocks LGPL, the fallback is a small internal mapping table seeded from the library's public data, which preserves most of the value at near-zero risk.
Maintenance. Low churn, low effort — but pin the version explicitly and review mapping-data diffs as behavioral changes, not routine bumps. Budget a recurring task: re-baseline the fixture corpus on every upgrade. If we ship custom YAML maps, that file becomes a product asset with an owner and a review process, not a config afterthought.
Support. Community-only, no vendor, no SLA. Internal ownership is mandatory: one named engineer accountable for upgrades, data review, and the upstream-watch/abandonment decision. Escalation path stops at us.
Scaling. Negligible: stateless, CPU-trivial, no network calls. The only scaling concern is per-process memory for the loaded map under PHP-FPM — load once per worker and cache the compiled result rather than re-parsing YAML per request. Under Octane, resolve it as a singleton at boot, not per request.
Failure modes to design for.
[0] will be non-deterministic across data updates.Content-Type disagreeing with nginx/CDN behavior produces download or inline-render bugs in production that reproduce nowhere else.Ramp-up. Hours, not weeks. The API surface is small and the mental model is simple. The real onboarding cost is the fixture corpus, the diff harness, and the legal/compliance conversation — all one-time and mostly independent of this package. A mid-level engineer can own it comfortably; the risk is organizational, not cognitive.
How can I help you explore Laravel packages today?