james-heinrich/getid3
PHP library for reading and parsing audio/video file metadata. Extracts tags (ID3, APE, Lyrics3) and technical info from many formats including MP3, AAC/MP4, FLAC, Ogg (Vorbis/Opus), WAV/AIFF, AVI/ASF, MKV, and more.
Strengths:
getID3 excels at parsing metadata from a broad spectrum of audio, video, and image formats, making it ideal for applications requiring file metadata analysis (e.g., media libraries, content management systems, or audio/video processing pipelines).Weaknesses:
unserialize()).error/warning arrays; 2.x throws exceptions. Inconsistent error handling may require wrapper logic in Laravel.getID3 as a singleton for dependency injection.php artisan media:scan).songs table with artist, album, duration fields).getID3 arrays) can be serialized to JSON columns (PostgreSQL/MySQL 5.7+).Storage::disk()->path().sys_get_temp_dir()).| Risk Area | Mitigation Strategy |
|---|---|
| Memory Usage | Load only required modules (e.g., getID3::MPEG instead of full library). |
| PHP Version Conflicts | Use composer require php:^8.0 + platform-check to enforce compatibility. |
| Deprecation | Fork/mirror the repo or replace with phpffmpeg for modern needs. |
| Error Handling | Wrap getID3 calls in try-catch blocks to convert exceptions to Laravel’s Problem responses. |
| Performance | Cache metadata in Redis or database to avoid reprocessing files. |
| Security | Validate file types (e.g., mime_type()) before processing to prevent DoS via malformed files. |
phpffmpeg (FFmpeg wrapper) or symfony/mime.intervention/image may suffice.create_function, call_user_func_array with variadic args)?getID3 as a bindable interface (e.g., MetadataExtractor) for loose coupling.
// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->singleton('getID3', function () {
return new \getID3();
});
}
Metadata::analyze($file)) to abstract getID3 usage.metadata.extracted events for reactive workflows (e.g., update search indexes).Storage::disk('public')->path($file).media table with JSON columns for nested data.
Schema::create('media', function (Blueprint $table) {
$table->id();
$table->string('path');
$table->json('metadata')->nullable();
$table->timestamps();
});
/demos/demo.basic.php to verify metadata extraction works for your file types.php -dmemory_limit=256M).app/Services/MediaMetadataService.php) to encapsulate getID3 logic.public function extract(string $filePath): array
{
$getID3 = app('getID3');
return $getID3->analyze($filePath);
}
ffmpeg CLI calls) with getID3.getID3 fails.| Component | Compatibility Notes |
|---|---|
| PHP 8.x | May require shim layer for deprecated functions (e.g., create_function). |
| Laravel 9/10 | No native conflicts, but memory limits may need adjustment (php.ini). |
| Composer | Install via composer require james-heinrich/getid3. |
| Windows/Linux | Test on both OSes; some file path handling may differ. |
| Docker | Ensure memory_limit in php.ini is set to 256M+ for full feature set. |
Metadata::updateTags($file, ['artist' => 'New Artist'])).artist is a string).file.uploaded).How can I help you explore Laravel packages today?