- How do I install athlon1600/youtube-downloader in a Laravel app?
- Install it with Composer using composer require athlon1600/youtube-downloader "^4.0". There is nothing else to publish or register, so you can immediately instantiate YouTubeDownloader and call getDownloadLinks() with a YouTube watch URL. Because the package has no Laravel glue, you typically wrap it in your own service class or interface and bind that in a service provider.
- Which Laravel and PHP versions does this YouTube downloader support?
- The package advertises PHP ^7.4 || ^8.0, which makes it installable on Laravel 8 through 11. On Laravel 10 and 11 the PHP floor is already 8.1 or higher, so the package's own floor is effectively moot on a current stack. Its dependency footprint is deliberately light, which keeps the risk of Composer conflicts with Laravel's dependency graph low.
- Does this package require yt-dlp, ffmpeg, Python or a JavaScript runtime?
- No. It is pure PHP with no shell calls, no exec(), no JavaScript interpreter and no Python or yt-dlp binary, which is its main architectural selling point compared with wrapping youtube-dl. It ships its own cURL-based HTTP layer instead of using Guzzle, so it does not depend on Illuminate\Http\Client either. The trade-off is that there is no ffmpeg-based merging, so you rely on the combined audio/video streams YouTube already exposes.
- How do I get audio-only or combined audio/video links with getDownloadLinks()?
- YouTubeDownloader::getDownloadLinks() returns a DownloadOptions object holding StreamFormat entries plus a VideoInfo object. getAllFormats() returns every stream, some audio-only and some combined audio/video, while helpers such as getCombinedFormats() and getFirstCombinedFormat() narrow the list for you. To serve audio-only downloads, filter getAllFormats() yourself for the audio streams you want to expose.
- Is there a Laravel service provider or facade for this package?
- No. The package ships no service provider, facade, config file or migrations, so installing it is not the same as integrating the feature. You own the container binding, configuration values and exception translation, which is typically a few hours of work. Wrapping the library behind your own interface also makes it swappable and mockable in tests.
- How do I handle errors when getDownloadLinks() fails?
- In version 4 the method throws YouTube\Exception\YouTubeException instead of returning an empty result, so wrap calls in try/catch and translate the exception into your application's own error type or HTTP response. Also check whether getAllFormats() is empty, since a successful parse can still yield no usable links. Log the original message so you can spot breakage caused by YouTube-side changes.
- Can this package download private or age-restricted YouTube videos?
- Private videos are not supported. Age-restricted content only works if you manually supply cookies exported from a browser session signed in to a real Google account. That makes it impractical for unattended multi-user applications, so treat restricted content as out of scope unless you can inject and refresh cookies yourself.
- Will this work in production for high-volume downloading, and does it handle YouTube throttling?
- The project's own To-Do list acknowledges throttling, with many videos served at under 100 kb/s, and there is no captcha or 429 mitigation built in. Returned googlevideo.com URLs are commonly bound to the requesting client's IP with short expiries, so handing a server-extracted URL to an end-user browser may fail. Verify that behaviour against your target formats before freezing your architecture, and plan your own rate limiting and retry policy.
- How reliable is a pure-PHP YouTube downloader compared with yt-dlp, and what are the alternatives?
- This library works by scraping and reverse-engineering YouTube's player JavaScript and signature/cipher scheme, so breakage is a steady state rather than an edge case, as the release history of cipher and endpoint fixes shows. It is effectively maintained by a single developer with no LTS branch, security disclosure process or commercial support, and major versions have introduced breaking changes. Alternatives are running a yt-dlp binary in a container, which brings back shell and patching overhead, or a third-party download API.
- How do I test or mock YouTube downloads in Laravel without calling YouTube?
- Because the package ships its own cURL Browser class rather than using Guzzle or Illuminate\Http\Client, Laravel's Http::fake() will not intercept its requests. Wrap YouTubeDownloader behind an interface you control and bind a fake implementation in your test suite instead. You can then unit test your service class against hand-built DownloadOptions and StreamFormat objects, keeping live YouTube calls out of CI.