项目作者: narrowspark

项目描述 :
:dart: PHP MIME Types Guesser and extension mapping.
高级语言: PHP
项目地址: git://github.com/narrowspark/mimetypes.git
创建时间: 2017-09-01T14:24:13Z
项目社区:https://github.com/narrowspark/mimetypes

开源协议:MIT License

下载


MIME Types

PHP MIME Types Guesser and extension mapper.







built with jshttp/mime-db.

Mime types mapping, the right way.

This library uses jshttp/mime-db as its default mapping which aggregates data from multiple sources and creates a single db.json making it the most complete mapping.

Installation

  1. composer require narrowspark/mimetypes

Use

This mime type guesser has support for all OS supported guesser.

  1. <?php
  2. use Narrowspark\MimeType\MimeType;
  3. // You can register custom guessers by calling the register() method
  4. MimeType::register('CustomGuesser');
  5. return MimeType::guess('image.gif'); // returns image/gif

You looking for the full mime type array? Just use:

  1. <?php
  2. use Narrowspark\MimeType\MimeTypesList;
  3. return MimeTypesList::MIMES; // returns array

If you like to use the build in php mime type guesser, just use:

  1. <?php
  2. use Narrowspark\MimeType\MimeTypeFileInfoGuesser;
  3. use Narrowspark\MimeType\MimeTypeFileBinaryGuesser;
  4. use Narrowspark\MimeType\MimeTypeExtensionGuesser;
  5. use Narrowspark\MimeType\MimeTypeFileExtensionGuesser;
  6. // Inspecting the file using finfo and relies on magic db files.
  7. return MimeTypeFileInfoGuesser::guess('image.gif'); // returns image/gif
  8. // Inspecting the file using file -b --mime
  9. return MimeTypeFileBinaryGuesser::guess('image.gif'); // returns image/gif
  10. // Inspecting the extension using mime type list
  11. return MimeTypeExtensionGuesser::guess('gif'); // returns image/gif
  12. // Inspecting the file using mime type list
  13. return MimeTypeFileExtensionGuesser::guess('image.gif'); // returns image/gif

Contributing

If you would like to help take a look at the list of issues and check our Contributing guild.

Note: Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

The Narrowspark mimetypes is open-sourced software licensed under the MIT license