ab /lib-mime
一个极其轻量级的、主要静态的MIME、内容类型和文件扩展名库。
v0.1.0
2019-10-15 08:40 UTC
Requires (Dev)
- phpunit/phpunit: ^8.4
This package is auto-updated.
Last update: 2024-09-11 01:42:25 UTC
README
一个极其轻量级的、主要静态的MIME、内容类型和文件扩展名库
安装
composer require ab/lib-mime
使用
一个示例路由脚本,用于传递资源
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); } // ... }());
许可证
在 "Unlicense" 许可下发布,属于公有领域。更多信息请参阅 https://unlicense.org。