mirror of
https://codeberg.org/vlw/php-mime-types.git
synced 2025-09-14 03:03:42 +02:00
Compare commits
No commits in common. "29345dd1657264b9db36f0ab083b07821aedf1e2" and "26c6bb250edef31c3fb517e9af3f6d7e399e7aa3" have entirely different histories.
29345dd165
...
26c6bb250e
1 changed files with 0 additions and 33 deletions
33
README.md
33
README.md
|
@ -1,33 +0,0 @@
|
|||
# MIME-type parser and abstraction library for PHP
|
||||
|
||||
Resolve MIME-types from file extensions and vice versa by passing a URL to an RFC 4288-compatible source to this library.
|
||||
|
||||
```php
|
||||
use vlw\MimeTypes\MimeTypes;
|
||||
|
||||
$mime = new MimeTypes("https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types");
|
||||
|
||||
// From string
|
||||
$mime->get_ext_from_type("image/webp"); // "webp"
|
||||
$mime->get_type_from_ext("webp"); // "image/webp"
|
||||
|
||||
// From pathname
|
||||
$mime->get_ext_from_file("path/to/file.webp"); // "webp"
|
||||
$mime->get_type_from_file("path/to/file.webp"); // "image/webp"
|
||||
```
|
||||
|
||||
# Installation
|
||||
|
||||
```sh
|
||||
composer require vlw/mime-types
|
||||
```
|
||||
|
||||
# Use
|
||||
|
||||
```php
|
||||
use vlw\MimeTypes\MimeTypes;
|
||||
|
||||
$mime = new MimeTypes(string $url);
|
||||
```
|
||||
|
||||
Defaults to [Apache's `mime.types` file from GitHub](https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types) if no value is provided to `$url`
|
Loading…
Add table
Reference in a new issue