ab / lib-mime
An extremely lightweight mostly static mime, content-type and file extension library.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ab/lib-mime
Requires (Dev)
- phpunit/phpunit: ^8.4
This package is auto-updated.
Last update: 2025-10-11 03:46:57 UTC
README
An extremely lightweight mostly static mime, content-type and file extension library
Install
composer require ab/lib-mime
Use
An example router script to pass through resources:
use ab\Mime\MimeTypeArray; (function () { $tryPath = $_SERVER['REQUEST_URI']; $filename = basename($tryPath); [$fileext,] = explode('.', strrev($filename), 2); $fileext = strrev($fileext); // .... $type = MimeTypeArray::getContentType($fileext); if ($type !== null) { header("Content-Type: $type", true); } else { header("Content-Type: application/octet-stream", true); } // ... }());
License
Released under the "Unlicense", which is public domain. Read more at https://unlicense.org.