- How do I install getID3() in a Laravel project?
- Run `composer require james-heinrich/getid3` in your project root. The package is autoloaded via Composer, so no additional configuration is needed for basic usage. For Laravel integration, register it as a service provider or facade to manage instances centrally.
- Which Laravel versions does getID3() support?
- getID3() works with PHP 5.3+, which aligns with Laravel 5.x and later. However, it lacks native support for Laravel’s newer features (e.g., PHP 8.2 attributes). Test thoroughly if using Laravel 9+ or 10+ to avoid compatibility issues.
- Can getID3() read metadata from MKV, MP4, or AVI files?
- Yes, getID3() supports MKV, MP4 (AAC), and AVI containers. It extracts technical details like codec, bitrate, duration, and embedded tags (e.g., ID3 for MP4, VorbisComments for MKV). Use `$fileinfo = getid3_info($filepath)` to retrieve structured data.
- How do I handle large files (e.g., 1GB videos) without timeouts?
- For large files, wrap processing in Laravel queues (e.g., `Bus::dispatch(new ProcessMediaJob($file))`) to avoid timeouts. Alternatively, use chunked reading or increase PHP’s `max_execution_time` and `memory_limit` temporarily for critical jobs.
- Does getID3() support writing metadata (e.g., updating ID3 tags)?
- Yes, getID3() can write metadata for supported formats (e.g., ID3v2, VorbisComments, APE). Use `getid3_lib::WriteTagsToFile($fileinfo, $filepath)` after modifying `$fileinfo['tags']`. Note: Writing requires additional error handling for corrupted files.
- Is getID3() compatible with Laravel’s filesystem (e.g., S3 storage)?
- Yes, getID3() works with Laravel’s filesystem adapters. Pass the file path (local or remote) to `getid3_info()`. For S3, ensure the file is temporarily downloaded to a local path or use a stream-compatible solution like `Storage::disk('s3')->get($path)`.
- What are the memory requirements for getID3()?
- Full module support requires ~12MB+ memory. For memory-constrained environments (e.g., shared hosting), disable unused modules via `getid3_include_path()` or process files asynchronously. Check `$fileinfo['error']` for memory-related warnings.
- Are there Laravel-specific integrations (e.g., Facades, Jobs) for getID3()?
- No, getID3() is a vanilla PHP library. You’ll need to create a Laravel service provider or facade (e.g., `Metadata::read($file)`) and wrap heavy operations in queueable jobs (e.g., `ProcessMediaJob`). Example: `Bus::dispatch(new ProcessMediaJob($filepath))`.
- What licenses are available, and which should I choose for Laravel?
- getID3() offers GPL, LGPL, MPL, or a legacy commercial license. For proprietary Laravel apps, use **LGPL or MPL** to avoid GPL’s viral effect. Review the `licenses/` directory in the package for terms. Dynamic linking (e.g., via Composer) may mitigate GPL risks.
- What alternatives exist for Laravel media metadata extraction?
- Alternatives include `spatie/laravel-medialibrary` (for images/audio), `php-ffmpeg` (video metadata), or `symfony/mime` (basic file info). For audio-specific needs, `james-heinrich/getid3` is unmatched in format support but lacks active maintenance. Consider forking or using `spatie` for image-heavy apps.