1. Go to this page and download the library: Download burakerenel/devtube library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
burakerenel / devtube example snippets
"bin_path" => "/usr/bin/youtube-dl",
namespace App\Http\Controllers;
use DevsWebDev\DevTube\Download;
class YoutubeDownloadController extends Controller
{
public function download()
{
$dl = new Download($url = "https://www.youtube.com/watch?v=ye5BuYf8q4o", $format = "mp4", $download_path = "music" );
//Saves the file to specified directory
$media_info = $dl->download();
$media_info = $media_info->first();
// Return as a download
return response()->download($media_info['file']->getPathname());
}
}
use DevsWebDev\DevTube\Download;
Route::get('/', function () {
$dl = new Download($url = "https://www.youtube.com/watch?v=ye5BuYf8q4o", $format = "mp3", $download_path = "music" );
//Saves the file to specified directory
$media_info = $dl->download();
$media_info = $media_info->first();
// Return as a download
return response()->download($media_info['file']->getPathname());
});