PHP YouTube Downloader

by Athlon1600



This project was inspired by a very popular youtube-dl python package:

Yes, there are multiple other PHP-based youtube downloaders on the Internet, but most of them haven't been updated in years, or they depend on youtube-dl itself.

Pure PHP-based youtube downloaders that work, and are kept-up-to date just do not exist.

This script does not depend on anything other than cURL. No Javascript interpreters, no calls to shell... nothing but pure PHP with no heavy dependencies either.

That's all there is to it!

Demo App

This may not work at all times, because YouTube puts a short ban on the server if it receives too many requests from it.

Deploy your own App

on Heroku:


Create a FREE account first if you do not yet have one:


Recommended way of installing this is via Composer:

composer require athlon1600/youtube-downloader

Run locally:

php -S localhost:8000 -t vendor/athlon1600/youtube-downloader/public


use YouTube\YouTubeDownloader;

$yt = new YouTubeDownloader();

$links = $yt->getDownloadLinks("");


Typical output:

array(13) {
  array(3) {
    string(820) ""
    string(23) "mp4, video, 360p, audio"
  array(3) {
    string(862) ""
    string(16) "mp4, video, 480p"
  array(3) {
    string(863) ""
    string(17) "webm, video, 480p"

If you are looking for links that include both video and audio in a single file, then filter down that list to look for links that contain both video and audio inside its format property.

Other Features

  • Stream YouTube videos directly from your server:
$youtube = new \YouTube\YouTubeStreamer();

How does it work

A more detailed explanation on how to download videos from YouTube will be written soon. For now, there is this:

Other Links

To-do list

  • Optional command that finds ALL video formats.
  • Fetch additional metadata about the video without using YouTube API.