定制 cosmicvelocity/media-types 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cosmicvelocity/media-types

Composer 安装命令:

composer require cosmicvelocity/media-types

包简介

Detect the Media Type (MIME Type) of a file or extentions.

README 文档

README

A PHP library for handling media types.

  • Supports the RFC 6838 specification.
  • MIME type character string analysis can be performed.
  • Supports automatic detection from filename with built-in mapping list.
  • Supports automatic detection by Fileinfo extension.

Installation

If composer is used, it can be introduced by adding the following description.

  "require": {
    "cosmicvelocity/media-types": ">=1.0"
  }

How to use

  • When detecting from file name.

    $mediaTypes = new PhpArrayMediaTypes();
    $mediaType = $mediaTypes->getMediaType('sample.txt');
    
    $mediaType->getType(); // text
    
  • To detect from your own mapping.

    $mediaTypes = new PhpArrayMediaTypes([
       'hoge' => 'application/prs.hoge+xml'
    ]);
    $mediaType = $mediaTypes->getMediaType('sample.hoge');
    
    $mediaType->getType();    // application
    $mediaType->getSubType(); // prs.hoge+xml
    $mediaType->getTree();  // prs
    $mediaType->getSuffix();  // xml
    
  • When analyzing MIME type.

    $mediaType = MediaType::fromMime('application/calendar+json; charset=utf-8');
    
    $mediaType->getType();    // application
    $mediaType->getSubType(); // calendar+json 
    $mediaType->getSuffix();  // json 
    $mediaType->getParameter('charset')->getValue(); // utf-8
    
  • When detecting from a file.

    $mediaType = MediaType::fromFile('sample.json');
    
    $mediaType->getType();    // text
    $mediaType->getSubType(); // plain
    

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2017-11-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固