diff --git a/.travis.yml b/.travis.yml index d68a22a..1fd9c99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: php php: - 7.3 - 7.4 + - 8.0 - nightly before_script: diff --git a/bin/generate.php b/bin/generate.php index 34fceae..bfb3f58 100755 --- a/bin/generate.php +++ b/bin/generate.php @@ -3,7 +3,13 @@ require_once dirname(__DIR__) . '/vendor/autoload.php'; -$mime_types_custom_text = file_get_contents(dirname(__DIR__) . '/mime.types.custom'); +$custom = dirname(__DIR__) . '/mime.types.custom'; +if(file_exists($custom)) { + $mime_types_custom_text = file_get_contents(dirname(__DIR__) . '/mime.types.custom'); +} else { + $mime_types_custom_text = ""; +} + $mime_types_text = file_get_contents(dirname(__DIR__) . '/mime.types'); $generator = new \Mimey\MimeMappingGenerator($mime_types_custom_text . PHP_EOL . $mime_types_text); diff --git a/bin/pull.php b/bin/pull.php new file mode 100755 index 0000000..6931fe9 --- /dev/null +++ b/bin/pull.php @@ -0,0 +1,18 @@ +#!/usr/bin/env php + array ( - 'wof' => - array ( - 0 => 'application/font-woff', - ), - 'php' => - array ( - 0 => 'application/php', - 1 => 'application/x-httpd-php', - 2 => 'application/x-httpd-php-source', - 3 => 'application/x-php', - 4 => 'text/php', - 5 => 'text/x-php', - ), - 'otf' => - array ( - 0 => 'application/x-font-otf', - 1 => 'font/otf', - ), - 'ttf' => - array ( - 0 => 'application/x-font-ttf', - 1 => 'font/ttf', - ), - 'ttc' => - array ( - 0 => 'application/x-font-ttf', - 1 => 'font/collection', - ), - 'zip' => - array ( - 0 => 'application/x-gzip', - 1 => 'application/zip', - ), - 'amr' => - array ( - 0 => 'audio/amr', - ), - 'mp3' => - array ( - 0 => 'audio/mpeg', - ), - 'mpga' => - array ( - 0 => 'audio/mpeg', - ), - 'mp2' => - array ( - 0 => 'audio/mpeg', - ), - 'mp2a' => - array ( - 0 => 'audio/mpeg', - ), - 'm2a' => - array ( - 0 => 'audio/mpeg', - ), - 'm3a' => - array ( - 0 => 'audio/mpeg', - ), - 'jpg' => - array ( - 0 => 'image/jpeg', - ), - 'jpeg' => - array ( - 0 => 'image/jpeg', - ), - 'jpe' => - array ( - 0 => 'image/jpeg', - ), - 'bmp' => - array ( - 0 => 'image/x-ms-bmp', - 1 => 'image/bmp', - ), 'ez' => array ( 0 => 'application/andrew-inset', @@ -2952,6 +2874,10 @@ array ( 0 => 'application/yin+xml', ), + 'zip' => + array ( + 0 => 'application/zip', + ), 'adp' => array ( 0 => 'audio/adpcm', @@ -2988,6 +2914,30 @@ array ( 0 => 'audio/mp4', ), + 'mpga' => + array ( + 0 => 'audio/mpeg', + ), + 'mp2' => + array ( + 0 => 'audio/mpeg', + ), + 'mp2a' => + array ( + 0 => 'audio/mpeg', + ), + 'mp3' => + array ( + 0 => 'audio/mpeg', + ), + 'm2a' => + array ( + 0 => 'audio/mpeg', + ), + 'm3a' => + array ( + 0 => 'audio/mpeg', + ), 'oga' => array ( 0 => 'audio/ogg', @@ -3000,6 +2950,10 @@ array ( 0 => 'audio/ogg', ), + 'opus' => + array ( + 0 => 'audio/ogg', + ), 's3m' => array ( 0 => 'audio/s3m', @@ -3144,6 +3098,18 @@ array ( 0 => 'chemical/x-xyz', ), + 'ttc' => + array ( + 0 => 'font/collection', + ), + 'otf' => + array ( + 0 => 'font/otf', + ), + 'ttf' => + array ( + 0 => 'font/ttf', + ), 'woff' => array ( 0 => 'font/woff', @@ -3152,6 +3118,10 @@ array ( 0 => 'font/woff2', ), + 'bmp' => + array ( + 0 => 'image/bmp', + ), 'cgm' => array ( 0 => 'image/cgm', @@ -3168,6 +3138,18 @@ array ( 0 => 'image/ief', ), + 'jpeg' => + array ( + 0 => 'image/jpeg', + ), + 'jpg' => + array ( + 0 => 'image/jpeg', + ), + 'jpe' => + array ( + 0 => 'image/jpeg', + ), 'ktx' => array ( 0 => 'image/ktx', @@ -3960,70 +3942,6 @@ ), 'extensions' => array ( - 'application/font-woff' => - array ( - 0 => 'wof', - ), - 'application/php' => - array ( - 0 => 'php', - ), - 'application/x-font-otf' => - array ( - 0 => 'otf', - ), - 'application/x-font-ttf' => - array ( - 0 => 'ttf', - 1 => 'ttc', - ), - 'application/x-gzip' => - array ( - 0 => 'zip', - ), - 'application/x-httpd-php' => - array ( - 0 => 'php', - ), - 'application/x-httpd-php-source' => - array ( - 0 => 'php', - ), - 'application/x-php' => - array ( - 0 => 'php', - ), - 'audio/amr' => - array ( - 0 => 'amr', - ), - 'audio/mpeg' => - array ( - 0 => 'mp3', - 1 => 'mpga', - 2 => 'mp2', - 3 => 'mp2a', - 4 => 'm2a', - 5 => 'm3a', - ), - 'image/jpeg' => - array ( - 0 => 'jpg', - 1 => 'jpeg', - 2 => 'jpe', - ), - 'image/x-ms-bmp' => - array ( - 0 => 'bmp', - ), - 'text/php' => - array ( - 0 => 'php', - ), - 'text/x-php' => - array ( - 0 => 'php', - ), 'application/andrew-inset' => array ( 0 => 'ez', @@ -6520,11 +6438,21 @@ 0 => 'm4a', 1 => 'mp4a', ), + 'audio/mpeg' => + array ( + 0 => 'mpga', + 1 => 'mp2', + 2 => 'mp2a', + 3 => 'mp3', + 4 => 'm2a', + 5 => 'm3a', + ), 'audio/ogg' => array ( 0 => 'oga', 1 => 'ogg', 2 => 'spx', + 3 => 'opus', ), 'audio/s3m' => array ( @@ -6698,6 +6626,12 @@ array ( 0 => 'ief', ), + 'image/jpeg' => + array ( + 0 => 'jpeg', + 1 => 'jpg', + 2 => 'jpe', + ), 'image/ktx' => array ( 0 => 'ktx', diff --git a/readme.md b/readme.md index a5c6ddf..eab4756 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ Mimey PHP package for converting file extensions to MIME types and vice versa. -[![Build Status](https://travis-ci.org/xantios/mimey.svg?branch=master)](https://travis-ci.org/xantios/mimey) +[![Build Status](https://www.travis-ci.com/Xantios/mimey.svg?branch=master)](https://travis-ci.org/xantios/mimey) [![Maintainability](https://api.codeclimate.com/v1/badges/1f8e322d2c73a16a1830/maintainability)](https://codeclimate.com/github/Xantios/mimey/) [![Latest Stable Version](https://img.shields.io/packagist/v/xantios/mimey.svg)](https://packagist.org/packages/xantios/mimey) [![Downloads per Month](https://img.shields.io/packagist/dm/xantios/mimey.svg)](https://packagist.org/packages/xantios/mimey) @@ -96,6 +96,14 @@ $builder = \Mimey\MimeMappingBuilder::load($cache_file_path); $mimes = new \Mimey\MimeTypes($builder->getMapping()); ``` +#### 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.