Skip to content

Commit

Permalink
Merge pull request #6 from Xantios/develop
Browse files Browse the repository at this point in the history
Preperation for V2.2.0
  • Loading branch information
Xantios authored Jun 12, 2021
2 parents f3e0b99 + beeecdc commit 8cb6f0c
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 145 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: php
php:
- 7.3
- 7.4
- 8.0
- nightly

before_script:
Expand Down
8 changes: 7 additions & 1 deletion bin/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions bin/pull.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$source = 'https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types';
$content = file_get_contents($source);

file_put_contents(getcwd().DIRECTORY_SEPARATOR."mime.types",$content);

print "Pulled new mime.types file. Run generate now? [y/N]";
$input = fopen("php://stdin","r");

if(strtolower(trim(fgets($input)))=="y") {
exec(getcwd().DIRECTORY_SEPARATOR.'bin/generate.php');
}

fclose($input);
2 changes: 1 addition & 1 deletion mime.types
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ audio/mp4 m4a mp4a
audio/mpeg mpga mp2 mp2a mp3 m2a m3a
# audio/mpeg4-generic
# audio/musepack
audio/ogg oga ogg spx
audio/ogg oga ogg spx opus
# audio/opus
# audio/parityfec
# audio/pcma
Expand Down
File renamed without changes.
218 changes: 76 additions & 142 deletions mime.types.php
Original file line number Diff line number Diff line change
@@ -1,84 +1,6 @@
<?php return array (
'mimes' =>
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',
Expand Down Expand Up @@ -2952,6 +2874,10 @@
array (
0 => 'application/yin+xml',
),
'zip' =>
array (
0 => 'application/zip',
),
'adp' =>
array (
0 => 'audio/adpcm',
Expand Down Expand Up @@ -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',
Expand All @@ -3000,6 +2950,10 @@
array (
0 => 'audio/ogg',
),
'opus' =>
array (
0 => 'audio/ogg',
),
's3m' =>
array (
0 => 'audio/s3m',
Expand Down Expand Up @@ -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',
Expand All @@ -3152,6 +3118,10 @@
array (
0 => 'font/woff2',
),
'bmp' =>
array (
0 => 'image/bmp',
),
'cgm' =>
array (
0 => 'image/cgm',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -6698,6 +6626,12 @@
array (
0 => 'ief',
),
'image/jpeg' =>
array (
0 => 'jpeg',
1 => 'jpg',
2 => 'jpe',
),
'image/ktx' =>
array (
0 => 'ktx',
Expand Down
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 8cb6f0c

Please sign in to comment.