{"id":21312554,"url":"https://github.com/dfridrich/phpmimetype","last_synced_at":"2025-07-12T00:33:13.616Z","repository":{"id":14457315,"uuid":"17169096","full_name":"dfridrich/PhpMimeType","owner":"dfridrich","description":"Simple PHP class for guessing file mime type based on file extension with ability to use in Symfony project.","archived":false,"fork":false,"pushed_at":"2023-12-09T11:28:40.000Z","size":191,"stargazers_count":16,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-21T08:47:27.387Z","etag":null,"topics":["mime-type","php","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfridrich.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-25T10:17:48.000Z","updated_at":"2024-05-16T16:21:45.000Z","dependencies_parsed_at":"2024-06-18T19:46:02.445Z","dependency_job_id":"7bdf1f4b-2a32-48c0-934f-57b369f33713","html_url":"https://github.com/dfridrich/PhpMimeType","commit_stats":{"total_commits":88,"total_committers":7,"mean_commits":"12.571428571428571","dds":0.09090909090909094,"last_synced_commit":"0bf47250c6451d8f29c5a741ee25fe5a0e39a644"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfridrich%2FPhpMimeType","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfridrich%2FPhpMimeType/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfridrich%2FPhpMimeType/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfridrich%2FPhpMimeType/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfridrich","download_url":"https://codeload.github.com/dfridrich/PhpMimeType/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225773836,"owners_count":17522075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mime-type","php","symfony"],"created_at":"2024-11-21T17:34:21.596Z","updated_at":"2024-11-21T17:34:22.062Z","avatar_url":"https://github.com/dfridrich.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/dfridrich"],"categories":[],"sub_categories":[],"readme":"# PhpMimeType v3\n\n[![Join the chat at https://gitter.im/dfridrich/PhpMimeType](https://badges.gitter.im/dfridrich/PhpMimeType.svg)](https://gitter.im/dfridrich/PhpMimeType?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Build Status](https://travis-ci.org/dfridrich/PhpMimeType.svg)](https://travis-ci.org/dfridrich/PhpMimeType)\n[![Latest Stable Version](https://poser.pugx.org/dfridrich/php-mime-type/v/stable)](https://packagist.org/packages/dfridrich/php-mime-type) \n[![Total Downloads](https://poser.pugx.org/dfridrich/php-mime-type/downloads)](https://packagist.org/packages/dfridrich/php-mime-type)\n[![Monthly Downloads](https://poser.pugx.org/dfridrich/php-mime-type/d/monthly)](https://packagist.org/packages/dfridrich/php-mime-type)\n[![License](https://poser.pugx.org/dfridrich/php-mime-type/license)](https://packagist.org/packages/dfridrich/php-mime-type)\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/dfridrich)\n\n![PhpMimeType](phpmimetype.png \"PhpMimeType\")\n\nSimple PHP class for guessing file mime type based on file extension with ability to use in Symfony project.\n\n## Install\n\n``` sh\ncomposer require dfridrich/php-mime-type\n```\n\n## Usage\n\n### Basic usage\n\n```php\n\u003c?php\n\n// from string, can be used on non-existing files\necho \\Defr\\PhpMimeType\\MimeType::get('index.php'); // outputs text/html\n\n// from SplFileInfo\necho \\Defr\\PhpMimeType\\MimeType::get(new \\SplFileInfo('Video.avi')); // outputs application/octet-stream\n\n// from SplFileObject\necho \\Defr\\PhpMimeType\\MimeType::get(new \\SplFileObject('Image.JPEG')); // outputs image/jpeg\n\n// from string\necho \\Defr\\PhpMimeType\\MimeType::get('someStrange.extension'); // outputs application/octet-stream\n\n// Multiple files\n$files = ['index.php', new \\SplFileInfo('Video.avi'), new \\SplFileObject('example.php')];\n/** @var \\Defr\\PhpMimeType\\MimeTypeInfo[] $mimeTypes */\n$mimeTypes = \\Defr\\PhpMimeType\\MimeType::multiple($files);\n\nforeach ($mimeTypes as $mimeType) {\n    echo sprintf('File \"%s\" is mime type \"%s\"', $mimeType-\u003egetFileName(), $mimeType-\u003egetMimeType()).'\u003cbr\u003e';\n}\n\n// Guess FontAwesome icon\necho \\Defr\\PhpMimeType\\MimeType::getFontAwesomeIcon('test.pdf'); // fa fa-file-pdf-o\n// ...with fixed width icon\necho \\Defr\\PhpMimeType\\MimeType::getFontAwesomeIcon('test.pdf', true); // fa fa-file-pdf-o fa-fw\n\n```\n\n### Symfony response\n\nIf you want to use Symfony response feature, install HTTP Foundation package too.\n\n``` sh\ncomposer require symfony/http-foundation\n```\n\nJust pass the file name or SPL object to response method and you will get Symfony\\Component\\HttpFoundation\\Response object.\nDisposition is **attachment** by default, you can chage it to **inline** or use Symfony ResponseHeaderBag's\nconstants DISPOSITION_ATTACHMENT or DISPOSITION_INLINE.\n\n```php\n\u003c?php\n\n// Return response to download this file as attachment (default)\n$response = \\Defr\\PhpMimeType\\MimeType::response(__FILE__);\n$response-\u003esend();\n\n// Return response to download this file inline\n$response = \\Defr\\PhpMimeType\\MimeType::response(__FILE__, \\Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::DISPOSITION_INLINE);\n$response-\u003esend();\n\n// You can use FileAsResponse object too (and own file name)\n$response = \\Defr\\PhpMimeType\\FileAsResponse::get(__FILE__, null, \"my-own-file-name.txt\");\n$response-\u003esend();\n\n// Or directly send it to browser\n$response = \\Defr\\PhpMimeType\\FileAsResponse::send(__FILE__);\n```\n\n### More examples and documentation\n\nSee [more examples](examples/).\n\nAPI documentation can be found [here](http://dfridrich.github.io/PhpMimeType/).\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Credits\n\n### Contributors\n\n* [Dennis Fridrich](https://github.com/dfridrich)\n* Nick Shek\n* [Giso Stallenberg](https://github.com/gisostallenberg)\n* [sml-joyo](https://github.com/sml-joyo)\n\n### Thanks to...\n\n* [freepik.com](http://www.freepik.com) - it provided photo in logo\n* [svogal](http://php.net/manual/en/function.mime-content-type.php#87856) - this guy inspired me to create this library\n* [colemanw](https://gist.github.com/colemanw/9c9a12aae16a4bfe2678de86b661d922) - his gist inspired me to add FontAwesome support\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfridrich%2Fphpmimetype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfridrich%2Fphpmimetype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfridrich%2Fphpmimetype/lists"}