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 range of audio, video, and image formats, making it ideal for applications requiring file metadata extraction (e.g., media libraries, content management systems, or audio/video processing pipelines).Weaknesses:
unpack(), fread(), and low-level file operations, which may trigger deprecation warnings in PHP 8+.Laravel Compatibility:
getID3 as a singleton, with optional configurable paths for temporary file storage.Metadata::extract($file)) for cleaner syntax.Database Synergy:
artist, album) can be cast to Eloquent attributes for easy querying.media_tags).API/CLI Use Cases:
POST /api/media/metadata).php artisan media:update-metadata).| Risk Area | Mitigation Strategy |
|---|---|
| PHP Version Mismatch | Use PHP 8.0+ with strict typing and wrap legacy functions in compatibility layers. |
| Memory Limits | Implement chunked processing for large files (e.g., streaming video). |
| File Handling | Use Laravel’s Storage facade for cross-platform file operations. |
| Concurrency | Offload heavy processing to Laravel Queues or background workers. |
| License Conflicts | Ensure compliance with GPL/LGPL (or use a commercial license if distributing closed-source). |
| Deprecated Functions | Replace unpack() with hex2bin() and modernize file I/O where possible. |
Scope of Use:
Performance Requirements:
Laravel Integration Depth:
Future-Proofing:
ffmpeg-php, symfony/mime) for specific use cases?Error Handling:
getID3 be surfaced to users or logged silently?Laravel Ecosystem:
Storage facade for local/S3/remote file access.Complementary Packages:
getID3 lacks support).Initial Setup:
composer require james-heinrich/getid3
GetID3ServiceProvider) to bind the library:
public function register()
{
$this->app->singleton('getid3', function () {
return new \getID3();
});
}
Wrapper Class:
Metadata) to abstract getID3:
class MetadataFacade extends Facade {
protected static function getFacadeAccessor() { return 'getid3'; }
}
public function extract($filePath) {
return app('getid3')->analyze($filePath);
}
public function updateTags($filePath, array $tags) {
// Implement tag writing logic
}
Queueable Jobs:
class ProcessMediaMetadata implements ShouldQueue {
use Dispatchable, InteractsWithQueue, Queueable;
public function handle() {
$metadata = Metadata::extract(storage_path('app/uploads/'.$this->file));
// Save to DB or cache
}
}
Database Integration:
Media):
protected $casts = [
'metadata' => 'array',
];
media_tags).API Endpoints:
Route::post('/media/metadata', function (Request $request) {
$file = $request->file('media');
$metadata = Metadata::extract($file->path());
return response()->json($metadata);
});
| Component | Compatibility Notes |
|---|---|
| PHP 8.1+ | May require strict type adjustments or compatibility layers for deprecated functions. |
| Laravel 9+ | Works, but namespacing and dependency injection may need manual setup. |
| Windows/Linux | File handling differences may require path normalization (e.g., str_replace('\\', '/', $path)). |
| S3/Cloud Storage | Use Laravel’s Storage::disk('s3')->path() for remote file access. |
| Docker | Ensure memory limits (12MB+) and temp dir permissions are configured. |
Phase 1: Core Integration
getID3 in a Service Provider/Facade.Phase 2: Laravel Integration
**Phase 3:
How can I help you explore Laravel packages today?