xdg/mime
最新稳定版本:1.0.4
Composer 安装命令:
composer require xdg/mime
包简介
PHP implementation of the Freedesktop Shared MIME-info Database standard.
README 文档
README
This package is a pure PHP implementation of the XDG Shared MIME-Info Database specification.
It is primarily aimed at MIME-type detection.
Installation
$ composer require xdg/mime
Usage
Implementation notes
Most XDG Shared MIME-Info implementations read their data from binary cache files
generated by the update-mime-database program.
This turns out to be impractical in the context of PHP for several reasons:
- First, PHP doesn't have native
mmapfunctionality, so reading these files at runtime can produce a lot of I/O. - Second, parsing these files at runtime has a non-negligible overhead.
- And last, PHP runs on server environments where the
update-mime-databaseprogram is often not available (and possibly even not installable).
Therefore, this library takes another approach: parsing the MIME database in its original XML format, and compiling it to executable PHP code. This yields several advantages:
- Since most PHP applications have a build / deploy step, the overhead of parsing the database at runtime is eliminated entirely.
- Generating PHP code allows leveraging the PHP opcode cache, which makes loading the database very fast.
- Since performance is less paramount at build time, the library does additional work to optimize the generated PHP code for optimal runtime performance.
For convenience, this package ships with a pre-compiled database, built from the latest shared-mime-info database.
统计信息
- 总下载量: 71
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-03