p3sdev/php-ytdlp-wrapper
Composer 安装命令:
composer require p3sdev/php-ytdlp-wrapper
包简介
Robust PHP 8.4 yt-dlp wrapper with Symfony 7 bundle integration
README 文档
README
Robust yt-dlp wrapper for PHP 8.4 with a ready-to-use Symfony 7 bundle.
✨ Features
- Safe process execution through
symfony/process - Structured request object (
YtDlpRequest) - Raw execution + JSON extraction helpers
- Strong error model (
BinaryNotFoundException,ProcessFailedException) - Symfony 7 service wiring and configurable bundle options
📋 Requirements
- PHP 8.4+
yt-dlpinstalled on the host machine (binary inPATHor custom path)
📦 Install
composer require p3sdev/php-ytdlp-wrapper
🧩 Symfony 7 Bundle Setup
1️⃣ Register bundle
If Symfony Flex does not auto-register it, add to config/bundles.php:
return [ // ... P3s\YtDlp\YtDlpBundle::class => ['all' => true], ];
2️⃣ Configure bundle
Create config/packages/yt_dlp.yaml:
yt_dlp: binary_path: 'yt-dlp' default_arguments: ['--no-warnings'] working_directory: ~ timeout: 300 environment: {}
🍱 Symfony Flex Recipe
A ready-to-submit Symfony Flex recipe scaffold is available in:
flex-recipe/1.0
To publish it for auto-install support, submit that recipe to symfony/recipes-contrib.
🚀 Usage in Symfony
Inject P3s\YtDlp\YtDlpClientInterface into your service:
<?php declare(strict_types=1); namespace App\Service; use P3s\YtDlp\YtDlpClientInterface; final class VideoService { public function __construct(private readonly YtDlpClientInterface $ytDlp) { } public function download(string $url): void { $result = $this->ytDlp->download($url, [ 'format' => 'bv*+ba/b', 'output' => '%(title)s.%(ext)s', 'paths' => '/tmp/videos', ]); $result->requireSuccessful(); } }
🛠️ Core API
⬇️ download(string|array $urls, array $options = []): ProcessResult
Runs yt-dlp for download/processing workflows.
🧠 rawJson(string|array $urls, array $options = []): ProcessResult
Runs metadata mode (--dump-json --skip-download --no-warnings) and returns full process output.
🔎 extractInfo(string|array $urls, array $options = []): array
Convenience method that returns parsed JSON lines.
⚙️ run(YtDlpRequest $request): ProcessResult
Low-level execution with full control over options, flags, and extra arguments.
🧾 YtDlpRequest
$request = YtDlpRequest::create( urls: ['https://www.youtube.com/watch?v=BaW_jenozKc'], options: [ 'format' => 'bestvideo+bestaudio/best', 'cookies' => '/secure/cookies.txt', 'proxy' => 'socks5://127.0.0.1:1080', 'playlist-items' => '1:3', 'print' => ['id', 'title'], ], flags: ['no-progress'], extraArguments: ['--'], );
⚠️ Errors
BinaryNotFoundException: custom binary path does not exist or is not executableProcessFailedException: command returned non-zero exit codeYtDlpException: base runtime exception
📝 Notes
- The wrapper maps options directly to
yt-dlpCLI flags (format->--format). - Arrays in option values are emitted as repeated flags.
- Boolean
trueemits a flag,falseis ignored.
📄 License
MIT. See LICENSE.
✅ CI
GitHub Actions runs tests on push and pull requests for PHP 8.4 and 8.5.
Workflow file: .github/workflows/tests.yml
p3sdev/php-ytdlp-wrapper 适用场景与选型建议
p3sdev/php-ytdlp-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「bundle」 「youtube」 「download」 「yt-dlp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 p3sdev/php-ytdlp-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 p3sdev/php-ytdlp-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 p3sdev/php-ytdlp-wrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
Bundle Symfony DaplosBundle
Provides a Data Grid tables for your Symfony project.
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-14