Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Youtube Dl Php

Youtube Dl Php Laravel Package

norkunas/youtube-dl-php

A PHP wrapper for youtube-dl and yt-dlp that downloads videos or extracts audio through a fluent Options API. Set download paths, formats, quality, and URLs, then iterate results with error handling and access downloaded files. Install via Composer.

View on GitHub
Deep Wiki
Context7

A PHP wrapper for youtube-dl or yt-dlp.

Frequently asked questions about Youtube Dl Php
How do I install norkunas/youtube-dl-php in a Laravel app?
Install it with Composer and pin a tagged release, for example composer require norkunas/youtube-dl-php:^2.14, instead of the dev-master command shown in the README. There are no migrations, config files, or service provider to publish, so you bind a configured YoutubeDl instance in your own service provider. You must also install the yt-dlp or youtube-dl binary on the machine that runs the code.
Do I need yt-dlp or youtube-dl installed on the server to use this package?
Yes. The package is a thin PHP wrapper that shells out to an external yt-dlp or youtube-dl binary through Symfony Process, so nothing downloads without it. Audio extraction also requires ffmpeg or avconv plus ffprobe or avprobe. Ship the binary in your container image and patch it on its own cadence, because platform changes break extractors regularly.
Which Laravel and PHP versions does norkunas/youtube-dl-php support?
The library is framework-agnostic but works cleanly with Laravel 10, 11, and 12 on the Symfony 6 and 7 lines. Version 2.9 dropped Symfony 4.4 and version 2.13 added Symfony 8 and PHP 8.5 support, so the supported matrix is current and forward-leaning. Check the released tags against your PHP and Symfony versions before locking, since the wrapper tracks Symfony releases rather than Laravel ones.
How do I download only audio or extract an MP3 with youtube-dl-php?
Build an Options object with downloadPath, then call extractAudio(true), audioFormat('mp3'), and audioQuality('0') for best quality, and set an output template such as %(title)s.%(ext)s. The downloaded audio file is available as an SplFileInfo from the resulting video object. This path requires ffmpeg and ffprobe to be installed and reachable by the PHP process.
Can I use youtube-dl-php inside a Laravel queue job?
Yes, and a dedicated queue worker is the right place for it because every download blocks on an external process and can take minutes. Dispatch a job, build your Options, run download, then persist metadata and move the SplFileInfo to a storage disk yourself, since the library does not manage storage or cleanup. The onProgress callback is a synchronous callback tied to the live process, so it only works inside a worker that can broadcast or push events, not in a web request.
How do I handle errors and access the downloaded file with this package?
download returns a Collection, so iterate getVideos and check getError() on each video before using it. On success you can call getTitle and getFile to get an SplFileInfo pointing inside your download path, plus other metadata accessors. Individual failures are surfaced per video through getError, so always inspect each result instead of assuming the collection contains only successes.
Is it safe to pass user-supplied URLs to youtube-dl-php?
Not by default. The wrapper executes a subprocess that fetches arbitrary remote content, which opens SSRF, local file access through insecure extractor flags, and resource exhaustion risks. Validate and strictly allow-list URLs against known hosts, keep yt-dlp hardened and updated, run workers with limited network and filesystem permissions, and never pass raw user input straight into the url option.
How do I set a custom yt-dlp binary path, timeout, or environment variables?
The 2.x line exposes a ProcessBuilderInterface seam that lets you change the binary, set timeouts, inject environment variables, or sandbox execution without forking the library. Implement your own process builder and inject it into the YoutubeDl instance you bind in Laravel's container. That is also the cleanest way to standardize flags and constraints across every download in your app.
How do I test code that uses norkunas/youtube-dl-php without downloading videos?
Do not hit real platforms in tests. Swap in a fake or stubbed ProcessBuilderInterface so the wrapper never launches a real yt-dlp process, and assert that your code builds the expected Options and handles the returned Collection. Keep one optional integration test behind an environment flag for a real binary if you need confidence in the shell-out path.
Is norkunas/youtube-dl-php actively maintained and production-ready?
The library is competently maintained with a steady pull request flow and current Symfony support, but ecosystem signal is low, at roughly 500 stars and effectively zero dependents. Production readiness depends more on the yt-dlp binary, which must be patched independently and frequently, than on the wrapper itself. If you adopt it, budget for owning that binary update cadence, and consider calling yt-dlp directly if you want to remove the extra layer.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo