- How do I install james-heinrich/getid3 in a Laravel application?
- Install it with Composer using composer require james-heinrich/getid3 and pin a version floor of at least 1.9.27 in composer.json so the XXE and compressed-frame fixes are always present. getID3 ships as a plain PHP library, so there is no auto-discovered Laravel service provider to register. After installation you reference the getID3 class from your own wrapper, job, or controller.
- Which Laravel and PHP versions does getID3 support?
- getID3 works on PHP 5.3 and newer, so it runs on every PHP version a modern Laravel application uses, including Laravel 5.8 through Laravel 11 and 12. It does not use namespaces, type hints, or PSR standards, so it will not conflict with Laravel but also will not benefit from autowiring or container resolution. Some low-level file functions it relies on may emit deprecation notices on PHP 8.x, which you can suppress or isolate inside a wrapper class.
- How do I read MP3 ID3 tags and audio metadata in Laravel with getID3?
- Instantiate getID3, call analyze() with the absolute path to the file, and read the returned associative array under the tags and audio keys. The result includes ID3v1, ID3v2, APE, and Lyrics3 tags plus technical details such as bitrate, sample rate, duration, and encoder. Store the values you need in Eloquent attributes or a JSON column, and expose them through an API resource if required.
- Can getID3 write or update ID3 tags and cover art?
- Yes. getID3 can write ID3v1, ID3v2, VorbisComments, APEv2, and Lyrics3 tags, which makes it usable for music library management or podcast metadata updates. Writing is done through the write module using a tag data array and a target file path, so wrap it in a service class and validate input before writing. Keep a backup or write to a copy of the file when processing user uploads.
- Which audio, video, and image formats does getID3 support?
- getID3 parses a very broad range of formats, including MP3, FLAC, Ogg Vorbis, Opus, AAC, MP4, WAV, AIFF, WMA, AVI, Matroska MKV, MPEG, QuickTime, and many legacy lossless and lossy codecs. It extracts both tags and technical stream information such as duration, bitrate, channels, and codec. This breadth is its main advantage over smaller tag-only libraries.
- How do I use getID3 with Laravel's service container and facade?
- Because getID3 has no namespaces and no Laravel integration, create a small wrapper class that instantiates getID3 and exposes methods like extract() or writeTags(). Bind that wrapper as a singleton in a service provider and optionally expose a facade such as Metadata::extract($path) for cleaner syntax. This also gives you one place to configure temporary paths and to mock the parser in tests.
- Is getID3 safe for parsing untrusted user uploads?
- Treat it as a security-sensitive dependency rather than a passive utility. Version 1.9.27 fixes an XXE issue by removing LIBXML_NOENT, repairs entity loader handling, and adds a maximum length cap on compressed ID3v2 frames to prevent decompression-based denial of service. Require 1.9.27 or later, never re-enable external entity loading around it, and pair it with upload size limits, memory limits, and per-job timeouts.
- Should I run getID3 metadata extraction in a Laravel queue?
- Yes for large files. Parsing video containers like MKV or MP4 can take seconds and risks hitting PHP's max execution time inside a web request. Dispatch a queued job that runs getID3 on the stored file and writes the results back to your model, and give the job a timeout so a malformed file cannot occupy a worker indefinitely.
- Does getID3 work with Laravel filesystem disks such as S3?
- getID3 needs a local file path, so with S3 or other remote disks you must download the object to a temporary location first, parse it, then delete the temp file. Laravel's Storage facade makes this straightforward with temporary URLs or a local temp disk. Always clean up temporary files in a finally block to avoid filling disk space.
- What are the alternatives to getID3 for metadata extraction in Laravel?
- getID3 is the most comprehensive pure-PHP option for reading and writing tags across many formats, and no dedicated Laravel package replaces it. Alternatives tend to be narrower, such as tag-only ID3 libraries or ffprobe wrappers that require the FFmpeg binary on the server. If you only need audio tags for MP3 and want a smaller footprint, a focused tag library may suffice, but for mixed audio and video metadata getID3 remains the broadest choice.