autoframe/components-filemime

Core File Mime Utils Autoframe Framework

3.0.0 2023-06-04 22:25 UTC

This package is auto-updated.

Last update: 2024-12-05 10:45:47 UTC


README

Build Status License: MIT Packagist Version Downloads

PHP server side file mime SOLID

Namespace:

  • Autoframe\Component\FileMime

Class is a SINGLETON:

  • AfrFileMimeClass + AfrFileMimeInterface + AfrFileMimeTrait
  • Methods:
    • getFileMimeTypes: array [... 'image/jpeg' => ['jpeg','jpg','jpe'], ...]
    • getFileMimeExtensions: array [... 'jpeg' => 'image/jpeg', ...]
    • getFileMimeFallback: string 'application/octet-stream'
    • getAllMimesFromFileName: array Input: '/dir/test.wmz' Output: ['application/x-ms-wmz','application/x-msmetafile'] (wmz extension has multiple mimes)
    • getMimeFromFileName: string Input: '/dir/test.jpg' Output: 'image/jpeg'
    • getExtensionsForMime: array Input: 'image/jpeg' Output: ['jpeg','jpg','jpe']
    • getExtensionFromPath: string Input: '/dir/test.jpg' Output: 'jpg'

Traits:

  • AfrFileMimeTypes public static array $aAfrFileMimeTypes = [...]
  • AfrFileMimeExtensions public static array $aAfrFileMimeExtensions = [...]

Utility class reads/updates the file 'mime.types' and writes new traits AfrFileMimeExtensions and AfrFileMimeTypes