|
1 | 1 | MIME type detection
|
2 | 2 | -------------------
|
3 |
| -The detection class `Media\Type` allows for detecting MIME types of files and |
| 3 | +The detection class `\mm\Mime\Type` allows for detecting MIME types of files and |
4 | 4 | streams by analyzing it's contents and/or extension. The class makes use of two
|
5 | 5 | adapters (`magic` and `glob`) which must be configured before using any of the
|
6 | 6 | methods and is thus "two-headed".
|
7 | 7 |
|
8 | 8 | Usage
|
9 | 9 | '''''
|
10 |
| -`Mime\Type::guessType(...)` |
| 10 | +`Type::guessType(...)` |
11 | 11 | Guesses the MIME type of the file.
|
12 | 12 |
|
13 | 13 | ```
|
14 |
| -Mime\Type::guessType('example.png'); // returns 'image/png' |
15 |
| -Mime\Type::guessType('/path/to/example.png'); // returns 'image/png' |
16 |
| -Mime\Type::guessType($handle = fopen('/path/to/example.png', 'rb')); // returns 'image/png' |
| 14 | +Type::guessType('example.png'); // returns 'image/png' |
| 15 | +Type::guessType('/path/to/example.png'); // returns 'image/png' |
| 16 | +Type::guessType($handle = fopen('/path/to/example.png', 'rb')); // returns 'image/png' |
17 | 17 | ```
|
18 | 18 |
|
19 |
| -`Mime\Type::guessExtension(...)` |
| 19 | +`Type::guessExtension(...)` |
20 | 20 | Guesses the extension (suffix) for an existing file or a MIME type.
|
21 | 21 |
|
22 | 22 | ```
|
23 |
| -Mime\Type::guessExtension('application/pdf'); // returns 'pdf' |
24 |
| -Mime\Type::guessExtension('/path/to/example.png'); // returns 'png' |
25 |
| -Mime\Type::guessExtension($handle = fopen('/path/to/example.png', 'rb')); // returns 'png' |
| 23 | +Type::guessExtension('application/pdf'); // returns 'pdf' |
| 24 | +Type::guessExtension('/path/to/example.png'); // returns 'png' |
| 25 | +Type::guessExtension($handle = fopen('/path/to/example.png', 'rb')); // returns 'png' |
26 | 26 | ```
|
27 | 27 |
|
28 |
| -`Mime\Type::guessName(...)` |
| 28 | +`Type::guessName(...)` |
29 | 29 | Determine the common lowercase media name, with and without hints from a magic
|
30 | 30 | lookup.
|
31 | 31 |
|
32 | 32 | ```
|
33 |
| -Mime\Type::guessName('example.png'); // returns 'image' |
34 |
| -Mime\Type::guessName('example.webm'); // returns 'video' |
35 |
| -Mime\Type::guessName('application/pdf'); // returns 'document' |
36 |
| -Mime\Type::guessName('/path/to/example.png'); // returns 'image' |
37 |
| -Mime\Type::guessName($handle = fopen('/path/to/example.png', 'rb')); // returns 'image' |
| 33 | +Type::guessName('example.png'); // returns 'image' |
| 34 | +Type::guessName('example.webm'); // returns 'video' |
| 35 | +Type::guessName('application/pdf'); // returns 'document' |
| 36 | +Type::guessName('/path/to/example.png'); // returns 'image' |
| 37 | +Type::guessName($handle = fopen('/path/to/example.png', 'rb')); // returns 'image' |
38 | 38 | ```
|
39 | 39 |
|
40 | 40 | Note: Most methods have additional options which give you more control about
|
41 | 41 | the output. Please consult the API documentation for more information
|
42 | 42 | on these options.
|
43 | 43 |
|
44 |
| -Available `Mime\Glob` Adapters |
| 44 | +Available `Glob` Adapters |
45 | 45 | ''''''''''''''''''''''''''''''
|
46 | 46 | `Apache`
|
47 | 47 | This adapter supports files like the ones that come with the `mod_mime_magic`
|
@@ -79,7 +79,7 @@ Can parse files containing one huge PHP array. Files must look like this:
|
79 | 79 | ]; ?>
|
80 | 80 | ```
|
81 | 81 |
|
82 |
| -Available `Mime\Magic` Adapters |
| 82 | +Available `Magic` Adapters |
83 | 83 | '''''''''''''''''''''''''''''''
|
84 | 84 | `Apache`
|
85 | 85 | This adapter supports files like the ones that come with the `mod_mime_magic`
|
|
0 commit comments