autoframe / components-filemime
Core File Mime Utils Autoframe Framework
3.0.0
2023-06-04 22:25 UTC
Requires
- php: ^7.4 || ^8.0
- autoframe/components-exception: ^1.0 || ^2.0
- autoframe/design-patterns: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.5 || ^10
README
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
- AfrFileMimeGeneratorClass
- Runs only in local tests (not from inside vendor dir)
- mime.types is updated from https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types