Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Mimetyper Laravel Package

adrienrn/php-mimetyper

A lightweight PHP library for MIME type mapping. Look up MIME types by file extension and extensions by MIME type through a simple API, useful for uploads, validation, and content headers without relying on file inspection.

Deep Wiki
Context7

Product Decisions This Supports

  • File upload and ingestion rules. Powers the "what do we accept?" decision across avatars, KYC documents, product images, CSV/XLSX imports, and email attachments. Extension↔MIME mapping is the data layer behind validation allow-lists, and getting it wrong is a support-ticket generator (a .jpg that arrives as application/octet-stream, an .xlsx rejected because the client sent application/zip).
  • Build vs. buy on a boring-but-maintained dataset. The code here is trivial; the value is the mime-db corpus and its upkeep. This forces the right framing: you are not buying a library, you are subscribing to a mapping table. If your team would otherwise hand-maintain a 200-line array of extensions, that array will be stale within two quarters — new formats (AVIF, HEIC, JXL, WebP variants, Office Open XML sub-types) land faster than most teams notice.
  • Correct Content-Type on delivery. Every download, invoice PDF, generated report, or user-uploaded asset served through Storage::download() / response()->file() depends on this mapping. A roadmap item like "self-serve media library" or "customer-facing document portal" implicitly assumes reliable type resolution; if it's wrong, browsers download instead of render, or render when they shouldn't.
  • Ecosystem parity decisions. Built on jshttp/mime-db — the same source Node's mime-types uses. If you run a PHP backend with a Node/TypeScript frontend, or are migrating services, this is a route to identical type resolution on both sides, which kills a class of "works in the uploader, fails in the API" bugs.
  • Security-adjacent scoping. Useful for deciding how much to invest in type handling: mapping is not sniffing. This package tells you what type an extension should be, not what the bytes are. That distinction should be an explicit line item in any upload-security epic, because it determines whether you also need finfo/libmagic content inspection.
  • Reverse lookups (type → extensions). Less obvious but real: deciding canonical extensions for export filenames, CDN cache-key suffixes, or "download as" menus.

When to Consider This Package

Adopt when:

  • You need extension → MIME and MIME → extension resolution in one place, framework-agnostic, with mime-db as the source of truth.
  • You want a small, standalone dependency rather than pulling in the full Symfony Mime component, or you're outside Symfony/Laravel and don't want framework coupling.
  • Cross-stack consistency matters — PHP services and JS tooling must agree on types.
  • You need reverse mapping (given image/jpeg, what extensions are valid?) as a first-class operation rather than an afterthought.
  • You accept the upstream data as the product: you'll pin a version, and refresh on a schedule rather than expecting the wrapper to be actively developed.

Look elsewhere when:

  • You're on Laravel and just need validation. mimes: / mimetypes: rules and UploadedFile::getMimeType() already work via Symfony Mime, which ships with the framework. Adding a second mapping source creates two truth-tellers that will eventually disagree. Confirm the gap before adopting.
  • You need real security. This maps, it doesn't sniff. For untrusted uploads you want content inspection (finfo_file, ClamAV, re-encoding images) plus size limits and storage isolation. Do not let a mapping library stand in for that control.
  • Maintenance risk is unacceptable. 24 stars, single maintainer, and the wrapper is thin. If your procurement or security review requires an active maintainer with a release cadence, the honest answer is to vendor the mime-db JSON yourself and write the 50-line lookup — MIT licensing makes that legitimate. Budget that as a fallback, not a failure.
  • You need behavior beyond mapping — type detection from bytes, content-disposition negotiation, streaming, image dimension probing. Wrong tool.

Decision rule: if two or more of {cross-stack parity, standalone/no-framework, reverse lookup} hold, adopt with a pinned version and a wrapper interface of your own. If none hold, use what the framework already gives you.

How to Pitch It (Stakeholders)

For executives: This is a small, low-cost dependency that replaces a hand-maintained lookup table with a continuously curated one, sourced from the same dataset the JavaScript ecosystem uses. The business value is in defect prevention, not features: fewer broken uploads, fewer mis-served documents, fewer "my file won't attach" support tickets. Cost is near zero; the material risk is maintenance — one maintainer, small community — which we mitigate by pinning a version behind our own thin interface and treating the underlying data as replaceable. Recommendation: adopt narrowly where it closes a real gap, do not adopt where the framework already covers it.

For engineering: It's a mime-db-backed mapper with Symfony/Laravel compatibility — bidirectional type/extension resolution, no content sniffing. It does not replace finfo, upload validation hardening, or image processing. Treat it as a data dependency: pin the version, refresh quarterly, and hide it behind a single internal service so a swap to vendored data is a one-file change. Be explicit that on Laravel, mimes:/mimetypes: already resolve through Symfony Mime — so the justification here has to be cross-stack parity, standalone use, or reverse lookups, not "we need MIME types."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings