Download the PHP package devanych/mime-types without Composer
On this page you can find all versions of the php package devanych/mime-types. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mime-types
Mime Types
This PHP package allows you to convert MIME types to file extensions and Vice versa, and to add your own MIME types and file extensions.
You can change the functionality by implementing interfaces:
-
Devanych\Mime\MimeTypesInterface - contains methods to implement the functionality.
- Devanych\Mime\MimeTypesMapsInterface - contains a map of MIME types and file extensions.
A guide with a detailed description in Russian language is available here.
Installation
This package requires PHP version 7.4 or later.
Usage MimeTypes
Creation:
Conversion:
Adding:
You can pass a map to the constructor when you create a
Devanych\Mime\MimeTypes
class, inside the constructor calls theaddMap()
method.
Usage MimeTypesAllowed
If you want to use only the allowed preset mime types and file extensions then use the Devanych\Mime\MimeTypesAllowed
instead of the Devanych\Mime\MimeTypes
.
When you create an instance of the Devanych\Mime\MimeTypesAllowed
class, you MUST pass the map. If you pass an empty or incorrect map, the exception \InvalidArgumentException
will be thrown.
When creating an instance of the
Devanych\Mime\MimeTypesAllowed
class, theaddMap()
method is called in the constructor, but for security reasons, a\LogicException
will be thrown if you try to call theaddMap()
method again.
The methods getMimeTypes()
and getExtensions()
work the same as in the Devanych\Mime\MimeTypes
, but the search is performed only in the preset mime types and file extensions that were passed to the constructor when creating an instance of the Devanych\Mime\MimeTypesAllowed
class.