- What Laravel versions does DevTube officially support?
- DevTube is designed for Laravel 12 and 13. While it may work with older versions (e.g., 8/9), you’ll need to test route model binding and PHP 8.3+ features like named arguments. The package leverages Laravel’s service provider pattern for seamless integration.
- How do I install yt-dlp and FFmpeg for DevTube?
- Install yt-dlp via pip (`python3 -m pip install -U yt-dlp`) and FFmpeg (Ubuntu/Debian: `sudo apt install ffmpeg`). For macOS, use Homebrew (`brew install ffmpeg`). Verify paths in `config/devtube.php` or set them via `.env` (e.g., `DEVTUBE_YT_DLP_PATH`). FFmpeg is only required for audio extraction (MP3).
- Can I customize download paths or file formats?
- Yes. Configure `download_path` in `config/devtube.php` to set a storage directory (relative to `storage_path()`). Define formats like `mp4` or `mp3` in the `formats` array, specifying yt-dlp options such as `extract_audio` or `audio_quality`. The `output_template` key controls filenames (e.g., `%(title)s.%(ext)s`).
- Does DevTube support async downloads to avoid blocking requests?
- No, DevTube performs downloads synchronously by default. For high-traffic apps, queue downloads using Laravel Queues (e.g., Horizon or Sidekiq). Wrap the `download()` call in a job and dispatch it to a worker. Monitor CPU usage during FFmpeg transcoding for large files.
- How do I handle errors if yt-dlp or FFmpeg fails?
- DevTube doesn’t include built-in retry logic, so wrap calls in try-catch blocks to handle exceptions. For critical downloads, implement a fallback (e.g., manual review or a backup queue). Log failures to track recurring issues, especially with malformed URLs or unsupported platforms.
- Is there a database table for tracking downloaded files?
- No, DevTube stores files on disk only. Create a `media` table to log metadata (URL, format, user_id, status) and access logs (download_count). Example fields: `url`, `path`, `status` (pending/processed/failed), and timestamps. Use Laravel’s Filesystem for safe path handling.
- Will DevTube work with YouTube Shorts or Live Streams?
- DevTube relies on yt-dlp, which may not fully support emerging formats like YouTube Shorts or Live Streams. Test with your target URLs, as yt-dlp’s compatibility depends on its upstream updates. For unsupported formats, consider pre-processing URLs or using a wrapper library.
- Are there alternatives to DevTube for Laravel video downloads?
- Alternatives include custom solutions using the [yt-dlp PHP wrapper](https://github.com/norkunas/youtube-dl-php) directly or packages like `spatie/laravel-youtube`. However, DevTube offers a Laravel-native facade and centralized config, reducing boilerplate. Evaluate based on your need for async support or modern Laravel features.
- How do I restrict downloads to specific domains (e.g., only YouTube)?
- Use yt-dlp’s `--restrict-filenames` or `--ignore-no-formats` options in `config/devtube.php` under a custom format. For whitelisting, add a middleware to validate URLs before passing them to DevTube, or extend the `Download` class to filter domains.
- Does DevTube support Laravel’s first-party testing tools (Pest, PHPUnit)?
- Yes, DevTube can be tested with Laravel’s testing tools. Mock the `DevTube` facade or use HTTP tests to verify downloads. Test edge cases like invalid URLs or missing binaries by temporarily modifying `config/devtube.php` or using environment variables to override paths.