PHPackages                             aronpc/youtube-comments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aronpc/youtube-comments

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aronpc/youtube-comments
=======================

A Laravel package to download YouTube comments without using API keys

v1.0.1(11mo ago)236[1 PRs](https://github.com/aronpc/youtube-comments-dump/pulls)MITPHPPHP &gt;=8.3

Since May 27Pushed 11mo agoCompare

[ Source](https://github.com/aronpc/youtube-comments-dump)[ Packagist](https://packagist.org/packages/aronpc/youtube-comments)[ RSS](/packages/aronpc-youtube-comments/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

YouTube Comments for Laravel
============================

[](#youtube-comments-for-laravel)

A Laravel package to download YouTube comments without using API keys, utilizing yt-dlp as the backend for extraction.

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 10.x or higher
- yt-dlp installed and accessible via terminal

Installation
------------

[](#installation)

1. Install the package via Composer:

    ```
    composer require aronpc/youtube-comments
    ```
2. The package will be automatically discovered by Laravel.
3. Publish the configuration file:

    ```
    php artisan vendor:publish --provider="AronPC\YouTubeComments\YouTubeCommentsServiceProvider" --tag="config"
    ```
4. Install yt-dlp (if not already installed):

    ```
    # Linux/macOS
    sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
    sudo chmod a+rx /usr/local/bin/yt-dlp

    # Windows
    # Download from https://github.com/yt-dlp/yt-dlp/releases and add to your PATH
    ```
5. Configure the package in `config/youtube-comments.php` if needed.

Usage
-----

[](#usage)

### Using Artisan Commands

[](#using-artisan-commands)

This package provides several Artisan commands to interact with YouTube comments and live chat.

#### Fetch Comments (All-in-one)

[](#fetch-comments-all-in-one)

To fetch comments from a YouTube video in a single step (download and parse), use the following command:

```
php artisan youtube:fetch-comments VIDEO_ID
```

Replace `VIDEO_ID` with the ID of the YouTube video. For example:

```
php artisan youtube:fetch-comments dQw4w9WgXcQ
```

This will generate a file in the configured output directory named `comments_VIDEO_ID.txt` containing all the comments from the video.

#### Fetch Live Chat

[](#fetch-live-chat)

To fetch live chat from a YouTube video that had a live stream, use:

```
php artisan youtube:fetch-livechat VIDEO_ID
```

This will generate a file in the configured output directory named `livechat_VIDEO_ID.txt` containing all the live chat messages from the video.

#### Fetch Both Comments and Live Chat

[](#fetch-both-comments-and-live-chat)

To fetch both comments and live chat in a single operation, use:

```
php artisan youtube:fetch-all VIDEO_ID
```

This will generate two files in the configured output directory:

- `comments_VIDEO_ID.txt` containing all the comments
- `livechat_VIDEO_ID.txt` containing all the live chat messages

If either comments or live chat are not available for the video, the command will still succeed but will display a warning message.

#### Download Comments Only

[](#download-comments-only)

If you want to only download the comments and save them as a JSON file (useful for debugging), use:

```
php artisan youtube:download-comments VIDEO_ID
```

This will generate a file in the configured output directory named `comments_VIDEO_ID.json` containing the raw JSON data.

#### Parse Comments Only

[](#parse-comments-only)

To parse previously downloaded comments from a JSON file, use:

```
php artisan youtube:parse-comments VIDEO_ID
```

This command expects a file named `comments_VIDEO_ID.json` to exist in the configured output directory.

### Using the Facade

[](#using-the-facade)

You can also use the provided facade to interact with the YouTube client directly in your code:

```
use AronPC\YouTubeComments\Facades\YouTubeComments;

// Fetch comments from a YouTube video
$commentsFile = YouTubeComments::fetchComments('dQw4w9WgXcQ');

// Fetch live chat from a YouTube video
$liveChatFile = YouTubeComments::fetchLiveChat('dQw4w9WgXcQ');

// Fetch both comments and live chat
$results = YouTubeComments::fetchCommentsAndLiveChat('dQw4w9WgXcQ');
$commentsFile = $results['comments'];
$liveChatFile = $results['livechat'];

// Download comments only (returns path to JSON file)
$jsonFile = YouTubeComments::downloadComments('dQw4w9WgXcQ');

// Parse comments from a JSON file
$outputFile = YouTubeComments::parseComments('dQw4w9WgXcQ', $jsonFile);
```

### Output Format

[](#output-format)

The parsed comments are saved in a text file with the following format:

```
Author:
Comment text

Author:
Comment text

```

How It Works
------------

[](#how-it-works)

1. The application uses yt-dlp to download the comments from the YouTube video
2. It processes the JSON data and formats the comments
3. The formatted comments are saved to a text file in the output directory

Configuration
-------------

[](#configuration)

The package configuration file is located at `config/youtube-comments.php` after publishing. It includes the following options:

```
return [
    // Directory where downloaded comments and live chat messages will be saved
    'output_directory' => env('YOUTUBE_COMMENTS_OUTPUT_DIR', storage_path('app/youtube-comments')),

    // Path to the youtube-dl or yt-dlp executable
    'youtube_dl_path' => env('YOUTUBE_DL_PATH', 'yt-dlp'),

    // Maximum time (in seconds) to wait for a command to complete
    'command_timeout' => env('YOUTUBE_COMMENTS_TIMEOUT', 300),
];
```

You can customize these settings by editing the configuration file or by setting the corresponding environment variables in your `.env` file.

Testing
-------

[](#testing)

The package includes a comprehensive test suite built with PHPUnit. The tests cover the main functionality of the package, including:

- Service classes (YouTubeClient)
- Command classes (FetchCommentsCommand, DownloadCommentsCommand, ParseCommentsCommand)

### Running Tests

[](#running-tests)

If you want to run the tests for this package, you can clone the repository and run:

```
composer install
composer test
```

Troubleshooting
---------------

[](#troubleshooting)

- Make sure yt-dlp is installed and accessible from the command line
- Some videos may have comments disabled, in which case no comments will be downloaded
- Future live events that haven't started yet don't have comments available
- If you encounter any issues, try updating yt-dlp to the latest version
- For video IDs that start with a hyphen (e.g., -6oKXN8D6BI), you need to use the `--` separator to prevent the shell from interpreting the ID as a command option: ```
    php artisan youtube:fetch-comments -- -6oKXN8D6BI
    ```

    Note: The package has special handling for video IDs that start with a hyphen to ensure they are processed correctly.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance51

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

355d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d9930bc506bb77f5bc11a9e4235c0e65ff4d4c713334fd6e501edf45772ed5e?d=identicon)[aronpc](/maintainers/aronpc)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aronpc-youtube-comments/health.svg)

```
[![Health](https://phpackages.com/badges/aronpc-youtube-comments/health.svg)](https://phpackages.com/packages/aronpc-youtube-comments)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
