Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/decodelabs/typify
Mime type detection tools for PHP
https://github.com/decodelabs/typify
mime-types php
Last synced: 1 day ago
JSON representation
Mime type detection tools for PHP
- Host: GitHub
- URL: https://github.com/decodelabs/typify
- Owner: decodelabs
- License: mit
- Created: 2021-04-08T14:25:52.000Z (almost 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-11-06T16:14:41.000Z (2 months ago)
- Last Synced: 2024-12-07T02:18:13.849Z (about 1 month ago)
- Topics: mime-types, php
- Language: PHP
- Homepage:
- Size: 61.5 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Typify
[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/typify?style=flat)](https://packagist.org/packages/decodelabs/typify)
[![Latest Version](https://img.shields.io/packagist/v/decodelabs/typify.svg?style=flat)](https://packagist.org/packages/decodelabs/typify)
[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/typify.svg?style=flat)](https://packagist.org/packages/decodelabs/typify)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/typify/integrate.yml?branch=develop)](https://github.com/decodelabs/typify/actions/workflows/integrate.yml)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat)](https://github.com/phpstan/phpstan)
[![License](https://img.shields.io/packagist/l/decodelabs/typify?style=flat)](https://packagist.org/packages/decodelabs/typify)### Mime type detection tools for PHP
Use typify to identify and apply mime types information to your files and responses.
_Get news and updates on the [DecodeLabs blog](https://blog.decodelabs.com)._
---
## Installation
```bash
composer require decodelabs/typify
```## Usage
### Importing
Typify uses [Veneer](https://github.com/decodelabs/veneer) to provide a unified frontage under
DecodeLabs\Typify
.
You can access all the primary functionality via this static frontage without compromising testing and dependency injection.### Detecting types
Detect a mime type for a file path:
```php
use DecodeLabs\Typify;echo Typify::detect(__FILE__);
// application/x-php
```Get known extensions for a type:
```php
use DecodeLabs\Typify;$exts = Typify::getExtensionsFor('text/plain');
// txt, text, conf, def, list, log, in
```Suggest an extension for a mime type:
```php
use DecodeLabs\Typify;echo Typify::getExtensionFor('text/plain');
// txt
```## Licensing
Typify is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.