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

Mime Db Laravel Package

jshttp/mime-db

The canonical MIME type database from jshttp, published as JSON. It maps file extensions to media types and includes metadata such as compression and charset, powering Node.js HTTP libraries like mime-types and Express.

Deep Wiki
Context7

mime-db is a comprehensive database of MIME types maintained by jshttp, providing metadata for media types used across web servers and applications. It aggregates data from IANA, Apache, nginx, and other sources into a single JSON file, making it a reliable reference for content-type detection and negotiation.

  • Covers thousands of MIME types with extensions, compressibility, and source metadata
  • Distributed as a single JSON database for easy programmatic use
  • Aggregates official and community registries for broad coverage
  • Powers the popular mime-types package and related jshttp modules
Frequently asked questions about Mime Db
Is jshttp/mime-db a Laravel or PHP package?
No, jshttp/mime-db is primarily a Node.js and JavaScript dataset distributed as a JSON file with no PHP classes or Laravel service provider. You can consume the JSON inside Laravel, but you must write the lookup wrapper yourself. For turnkey PHP detection, pair it with finfo or Laravel's built-in MIME helpers.
How do I install and wire mime-db into a Laravel app?
Install it with Composer if your registry exposes it, or copy the db.json asset into resources, storage, or a package directory. Decode it once with json_decode into an associative array and bind that array as a singleton in a service provider. There is no auto-discovery, so register any wrapper class or facade manually.
How do I use mime-db for Content-Type headers in Laravel responses?
Load the database once, build lookup maps for extension-to-type and type-to-extension, then set headers with response()->json, response()->file, or Response::make. Always fall back to application/octet-stream when no match exists. Cache the decoded maps so header generation stays cheap on every request.
Can mime-db validate uploaded files in Laravel?
It gives you authoritative type and extension mappings, but it does not inspect file contents. Use it to build whitelists and normalize expected types, then combine those rules with Laravel's mimes or mimetypes validation and finfo_file for real detection. Never trust the client-supplied Content-Type header alone.
How does mime-db compare to Laravel and Symfony MIME detection?
Laravel relies on Symfony Mime and fileinfo for extension guessing and content inspection. mime-db is a static JSON dataset with charsets, compressible flags, and sources, but no guessing logic. Use mime-db for deterministic lookups and metadata, and keep Symfony Mime or finfo for runtime detection.
Which Laravel and PHP versions can use mime-db?
The dataset is version-agnostic JSON, so any PHP 8.1+ application, including Laravel 9 through 11, can decode it. Compatibility risk comes from your wrapper code, not the data itself. Pin a mime-db version and schedule updates so newer media types are not missed.
What should I return when mime-db has no matching type?
Fall back to application/octet-stream for unknown binary content, text/plain for plain text, or application/json when the payload is clearly JSON. Combine the fallback with finfo for runtime detection of unrecognized extensions. Log misses so you can add custom overrides for proprietary formats.
Should I cache mime-db data in Laravel?
Yes. Read and decode db.json once, then store the lookup arrays in a singleton, config cache, or Redis-backed Laravel cache. Avoid parsing the full JSON on every request in high-throughput APIs. Keyed array lookups are effectively O(1) after the initial load.
How do I extend mime-db with custom MIME types?
Because the dataset is static, merge your own overrides after decoding rather than editing vendor files. Keep custom mappings in a separate config array using the same type, extensions, and source shape. This preserves easy updates and makes proprietary formats explicit in code review.
Is mime-db maintained, and what are the alternatives for Laravel?
jshttp maintains mime-db under the MIT license and publishes periodic data updates, but it is a static dataset rather than a runtime service. Schedule dependency updates or refresh the JSON through a Laravel task or CI job, and test critical types after each bump. Alternatives include Symfony Mime, league/mime-type-detection, and PHP's finfo extension.
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.
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment