Download .zip |
Info | Documentation | View files (15) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2018-04-08 (5 months ago) | Not enough user ratings | Total: 145 | All time: 8,622 This week: 307 |
Version | License | PHP version | Categories | |||
php-mimetype 1.1.6 | MIT/X Consortium ... | 5.6 | PHP 5, Files and Folders |
PHP library for obtain headers MIME.
This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.
The preferred way to install this extension is through Composer.
To install PHP MimeType library, simply:
$ composer require Josantonius/MimeType
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
$ composer require Josantonius/MimeType --prefer-source
You can also clone the complete repository with Git:
$ git clone https://github.com/Josantonius/PHP-MimeType.git
Or install it manually:
Download MimeType.php and MimeTypesCollection.php:
$ wget https://raw.githubusercontent.com/Josantonius/PHP-MimeType/master/src/MimeType.php
$ wget https://raw.githubusercontent.com/Josantonius/PHP-MimeType/master/src/MimeTypesCollection.php
Available methods in this library:
MimeType::get();
# Return (void)
MimeType::getMimeFromExtension($ext);
| Attribute | Description | Type | Required | --- | --- | --- | --- | | $ext | File extension. | string | Yes |
# Return (string|false) ? MIME type or false
MimeType::getExtensionFromMime($mime);
| Attribute | Description | Type | Required | --- | --- | --- | --- | | $mime | MIME type. | string | Yes |
# Return (string|false) ? File extension or false.
To use this library with Composer:
require __DIR__ . '/vendor/autoload.php';
use Josantonius\MimeType\MimeType;
Or If you installed it manually, use it:
require_once __DIR__ . '/MimeType.php';
require_once __DIR__ . '/MimeTypesCollection.php';
use Josantonius\MimeType\MimeType;
Example of use for this library:
<?php
require __DIR__ . '/vendor/autoload.php';
use Josantonius\MimeType\MimeType;
echo MimeType::getMimeFromExtension('.json'); // application/json
echo MimeType::getExtensionFromMime('text/html'); // .html
var_dump(MimeType::get());
/*
array(682) {
[".123"]=>
string(27) "application/vnd.lotus-1-2-3"
[".3dml"]=>
string(18) "text/vnd.in3d.3dml"
[".3g2"]=>
string(11) "video/3gpp2"
[".3gp"]=>
string(10) "video/3gpp"
[".7z"]=>
string(27) "application/x-7z-compressed"
[".aab"]=>
string(28) "application/x-authorware-bin"
[".aac"]=>
string(11) "audio/x-aac"
[".aam"]=>
string(28) "application/x-authorware-map"
[".aas"]=>
string(28) "application/x-authorware-seg"
[".abw"]=>
string(21) "application/x-abiword"
(...)
*/
To run tests you just need composer and to execute the following:
$ git clone https://github.com/Josantonius/PHP-MimeType.git
$ cd PHP-MimeType
$ composer install
Run unit tests with PHPUnit:
$ composer phpunit
Run PSR2 code standard tests with PHPCS:
$ composer phpcs
Run PHP Mess Detector tests to detect inconsistencies in code style:
$ composer phpmd
Run all previous tests:
$ composer tests
If you would like to help, please take a look at the list of issues or the To Do checklist.
Pull requests
composer install
to install the dependencies.
This will also install the dev dependencies.composer fix
to excute code standard fixers.Thank you to all the people who already contributed to this project!
<img alt="vincent-guesnard" src="https://avatars3.githubusercontent.com/u/315173?v=4&s=117" height="117" width="117">|<img alt="MASNathan" src="https://avatars0.githubusercontent.com/u/2139464?v=4&s=117" height="117" width="117"> :---:|:---:| vincent-guesnard|MASNathan|
The file structure from this repository was created with PHP-Skeleton.
This project is licensed under MIT license. See the LICENSE file for more info.
2016 - 2018 Josantonius, josantonius.com
If you find it useful, let me know :wink:
Files |
File | Role | Description | ||
---|---|---|---|---|
src (2 files) | ||||
tests (1 file) | ||||
.editorconfig | Data | Auxiliary data | ||
.php_cs.dist | Example | Example script | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONDUCT.md | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpcs.xml | Data | Auxiliary data | ||
phpmd.xml | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README-ES.md | Doc. | Documentation | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description |
---|---|---|
MimeType.php | Class | Class source |
MimeTypesCollection.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.