Download the PHP package componenta/mimetype-detector without Composer
On this page you can find all versions of the php package componenta/mimetype-detector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download componenta/mimetype-detector
More information about componenta/mimetype-detector
Files in componenta/mimetype-detector
Package mimetype-detector
Short Description MIME type detection helpers for Componenta
License MIT
Informations about the package mimetype-detector
Componenta MIME Type Detector
MIME type and file-extension detection with value objects and a local MIME map.
Installation
The package declares Componenta\Detector\ConfigProvider in extra.componenta.config-providers.
When componenta/composer-plugin is installed, the provider is added to the generated provider list automatically.
Requirements
- PHP 8.4+
fileinfoextension- PSR-7 stream interfaces from
psr/http-message
Related Packages
This package is standalone but requires the PHP fileinfo extension.
| Package | Why it may be used nearby |
|---|---|
componenta/validation |
MIME/file rules can use the detector for uploaded files. |
componenta/http-responder |
File responses can use MIME types for content headers. |
componenta/image-converter |
Media flows can detect a format before conversion. |
What It Provides
MimeType: parsed MIME type value object.Ext: normalized file extension value object.MimeMapInterfaceandMimeMap: MIME-to-extension and extension-to-MIME mapping.FinfoDetector:fileinfo-based detector for strings, streams, and files.DetectorInterface: combined contract for MIME type, extension, file MIME type, and file extension detection.- Smaller contracts:
MimeTypeDetectorInterface,ExtensionDetectorInterface,FileMimeTypeDetectorInterface, andFileExtensionDetectorInterface. ConfigProvider: registers the default detector and map services in Componenta applications.- Typed exceptions for missing/unreadable files and invalid MIME types.
MIME Types
Invalid MIME strings throw InvalidMimeTypeException.
Extensions
MIME Map
Detection
Pass asObject: true to return MimeType or Ext objects.
FinfoDetector reads up to 8192 bytes from files and streams. Seekable streams are rewound for detection and then restored to their previous position. Non-seekable streams are read from the current position, so callers should provide them at the correct offset.
File detection throws FileNotFoundException, FileNotReadableException, or DetectorException for I/O failures.