- How do I install ACMediaInfoBundle in a Laravel 5.4+ project?
- Install via Composer (`composer require ac/media-info-bundle`), then register the bundle in `config/app.php` under 'providers' or manually bind the service to Laravel’s container. For Symfony bundles, use a bridge like `symfony/bundle` to integrate with Laravel’s kernel.
- What Laravel versions does ACMediaInfoBundle support?
- The bundle works with Laravel 4+ (via Symfony 2+ kernel) but requires manual registration in Laravel 5.4+. For newer Laravel versions, ensure compatibility with Symfony’s bundle system or adapt the service container binding to Laravel’s DI patterns.
- Do I need to install MediaInfo separately, and how?
- Yes, MediaInfo must be installed system-wide. On Linux/macOS, use package managers (e.g., `apt install mediainfo` or `brew install mediainfo`). On Windows, download the binary from [MediaArea.net](http://mediaarea.net/en/MediaInfo) and add it to your PATH. Configure the path in `config/ac_media_info.yml`.
- How do I scan a file and access its metadata in Laravel?
- Inject the `ac.mediainfo` service via dependency injection or fetch it from the container (`$container->get('ac.mediainfo')`). Call `$mediainfo->scan('/path/to/file')` to return a structured array with lowercase keys. Example: `$metadata = $mediainfo->scan(storage_path('video.mp4'));`.
- What happens if MediaInfo isn’t installed or fails to execute?
- The bundle will throw exceptions if MediaInfo is missing or unexecutable. Handle failures gracefully by wrapping calls in try-catch blocks or implementing a fallback (e.g., logging errors or using a pure-PHP alternative like `getid3`).
- Can I use this bundle in production for high-volume metadata extraction?
- The bundle performs synchronous scans, which may bottleneck in high-throughput systems. For production, consider offloading scans to a queue (e.g., Laravel Queues) or containerizing MediaInfo in a sidecar service to avoid blocking I/O.
- How do I export metadata to YAML or JSON for debugging?
- Use the built-in console command: `php artisan mediainfo:scan /path/to/file`. This outputs structured metadata in YAML format. For JSON, parse the returned array and encode it with `json_encode()`.
- Are the metadata keys consistent across different file types?
- Yes, all keys are normalized to lowercase, but MediaInfo’s output structure varies by file type. Multi-value fields (e.g., `video_format_list`) are returned as arrays. Review the raw output for edge cases, like unsupported formats or malformed metadata.
- Is there PHP 8.x support, or do I need polyfills?
- The bundle lacks explicit PHP 8.x support (last updated in 2016). Add `ext-ctype` and `ext-json` to `composer.json` and use polyfills for `return_type_declaration` and `strict_types` if needed. Test thoroughly, as MediaInfo’s CLI output parsing may require adjustments.
- What are the alternatives to ACMediaInfoBundle for Laravel?
- Consider pure-PHP libraries like `getid3` (supports more formats but slower) or `php-mediainfo` (PHP port of MediaInfo, no CLI dependency). For Symfony/Laravel, evaluate `spatie/media-library` (for file management) or custom CLI wrappers for other tools like `ffprobe`.