2017 © Pedro Peláez
 

library media-types

Detect the Media Type (MIME Type) of a file or extentions.

image

cosmicvelocity/media-types

Detect the Media Type (MIME Type) of a file or extentions.

  • Wednesday, April 11, 2018
  • by cosmicvelocity
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

cosmicvelocity/media-types

A PHP library for handling media types., (*1)

  • Supports the RFC 6838 specification.
  • MIME type character string analysis can be performed.
  • Supports automatic detection from filename with built-in mapping list.
  • Supports automatic detection by Fileinfo extension.

Installation

If composer is used, it can be introduced by adding the following description., (*2)

  "require": {
    "cosmicvelocity/media-types": ">=1.0"
  }

How to use

  • When detecting from file name., (*3)

    $mediaTypes = new PhpArrayMediaTypes(); $mediaType = $mediaTypes->getMediaType('sample.txt');, (*4)

    $mediaType->getType(); // text, (*5)

  • To detect from your own mapping., (*6)

    $mediaTypes = new PhpArrayMediaTypes([ 'hoge' => 'application/prs.hoge+xml' ]); $mediaType = $mediaTypes->getMediaType('sample.hoge');, (*7)

    $mediaType->getType(); // application $mediaType->getSubType(); // prs.hoge+xml $mediaType->getTree(); // prs $mediaType->getSuffix(); // xml, (*8)

  • When analyzing MIME type., (*9)

    $mediaType = MediaType::fromMime('application/calendar+json; charset=utf-8');, (*10)

    $mediaType->getType(); // application $mediaType->getSubType(); // calendar+json $mediaType->getSuffix(); // json $mediaType->getParameter('charset')->getValue(); // utf-8, (*11)

  • When detecting from a file., (*12)

    $mediaType = MediaType::fromFile('sample.json');, (*13)

    $mediaType->getType(); // text $mediaType->getSubType(); // plain, (*14)

The Versions

11/04 2018

dev-master

9999999-dev

Detect the Media Type (MIME Type) of a file or extentions.

  Sources   Download

Apache-2.0 Apache License 2.0

The Requires

  • php ^5.4|^7.0

 

The Development Requires

by Kouichi Machida

mime php mimetypes contenttype mediatype

11/04 2018

1.2

1.2.0.0

Detect the Media Type (MIME Type) of a file or extentions.

  Sources   Download

Apache-2.0

The Requires

  • php ^5.4|^7.0

 

The Development Requires

by Kouichi Machida

mime php mimetypes contenttype mediatype

11/04 2018

1.1

1.1.0.0

Detect the Media Type (MIME Type) of a file or extentions.

  Sources   Download

Apache-2.0

The Requires

  • php ^5.6|^7.0

 

The Development Requires

by Kouichi Machida

mime php mimetypes contenttype mediatype

23/07 2017

1.0

1.0.0.0

Detect the Media Type (MIME Type) of a file or extentions.

  Sources   Download

Apache License 2.0

The Requires

  • php ^5.6|^7.0

 

The Development Requires

by Kouichi Machida

mime php mimetypes contenttype mediatype