Download the PHP package xantios/mimey without Composer
On this page you can find all versions of the php package xantios/mimey. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xantios/mimey
More information about xantios/mimey
Files in xantios/mimey
Package mimey
Short Description PHP package for converting file extensions to MIME types and vice versa.
License MIT
Informations about the package mimey
Mimey
PHP package for converting file extensions to MIME types and vice versa.
This package uses httpd's mime.types to generate a mapping of file extension to MIME type and the other way around.
The mime.types
file is parsed by bin/generate.php
and converted into an optimized PHP array in mime.types.php
which is then wrapped by helper class \Mimey\MimeTypes
.
Usage
Getting All
It's rare, but some extensions have multiple MIME types:
However, there are many MIME types that have multiple extensions:
Custom Conversions
You can add custom conversions by changing the mapping that is given to MimeTypes
.
There is a MimeMappingBuilder
that can help with this:
You can add as many conversions as you would like to the builder:
Optimized Custom Conversion Loading
You can optimize the loading of custom conversions by saving all conversions to a compiled PHP file as part of a build step.
The file can then be loaded to avoid overhead of repeated $builder->add(...)
calls:
Programmatically or manually add custom type mappings
You can rename the included mime.types.custom.example
to mime.types.custom
and recompile. the custom entries always take precedence over built-in defitions.
Updating (advanced)
In case there is a update in the httpd defined types you can run bin/pull.php
in this repo to pull new mime files and compile them
Install
Compatible with PHP >= 5.4.
Credits
Original version created by rodolfoberrios