PHPackages                             vhar/laravel-videos - 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. [Database &amp; ORM](/categories/database)
4. /
5. vhar/laravel-videos

ActiveLibrary[Database &amp; ORM](/categories/database)

vhar/laravel-videos
===================

Attach videos from popular hosting platforms to Eloquent models

1.0.0(1mo ago)01MITPHPPHP ^8.2

Since Jul 10Pushed 1mo agoCompare

[ Source](https://github.com/vhar/laravel-videos)[ Packagist](https://packagist.org/packages/vhar/laravel-videos)[ Docs](https://github.com/vhar/laravel-videos)[ RSS](/packages/vhar-laravel-videos/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

```
# Laravel Videos

Attach videos from popular hosting platforms to Eloquent models.

Laravel Videos provides a simple and consistent API for associating external videos with your Eloquent models. It automatically detects the video provider, extracts metadata, and stores everything in a single `videos` table.

## Features

- Supports Laravel 11 and 12
- Automatic package discovery
- Polymorphic Eloquent relationship
- Video collections
- Automatic provider detection
- Stores video metadata
- Extensible provider architecture

### Built-in providers

- YouTube
- Vimeo
- VK Video
- Rutube
- Dailymotion

## Installation

Install the package via Composer:

```bash
composer require vhar/laravel-videos
```

Run the migrations:

```bash
php artisan migrate
```

## Usage

### Add the trait

```php
use Vhar\LaravelVideos\Traits\HasVideos;

class Post extends Model
{
    use HasVideos;
}
```

### Add a video

```php
$post->videos()->createFromUrl(
    'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
);
```

Or specify a collection:

```php
$post->videos()->createFromUrl(
    'https://vimeo.com/76979871',
    'intro'
);
```

### Retrieve videos

Get all videos:

```php
$post->videos()->get();
```

Get videos from a collection:

```php
$post->videos('intro')->get();
```

Get the first video:

```php
$post->video();
```

Get the first video from a collection:

```php
$post->video('intro');
```

## Video model

Each video stores the following information:

| Field | Description |
|--------|-------------|
| provider | Video provider name |
| url | Original video URL |
| video_id | External video identifier |
| embed_url | Video embed URL |
| title | Video title |
| thumbnail | Thumbnail URL |
| duration | Duration in seconds |
| collection | Optional collection name |

## Supported URLs

### YouTube

```
https://www.youtube.com/watch?v=...
https://youtu.be/...
https://www.youtube.com/shorts/...
```

### Vimeo

```
https://vimeo.com/...
https://player.vimeo.com/video/...
```

### VK Video

```
https://vkvideo.ru/video...
https://vk.com/video...
```

### Rutube

```
https://rutube.ru/video/...
https://rutube.ru/play/embed/...
```

### Dailymotion

```
https://www.dailymotion.com/video/...
https://dai.ly/...
```

## Custom providers

Create a class implementing the `VideoProvider` contract:

```php
use Vhar\LaravelVideos\Contracts\VideoProvider;

class CustomProvider implements VideoProvider
{
    // ...
}
```

Register it in the configuration file:

```php
'providers' => [

    \App\Videos\CustomProvider::class,

],
```

## License

The MIT License (MIT).
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5484416?v=4)[Vladimir Kharinenkov](/maintainers/vhar)[@vhar](https://github.com/vhar)

---

Top Contributors

[![vhar](https://avatars.githubusercontent.com/u/5484416?v=4)](https://github.com/vhar "vhar (1 commits)")

---

Tags

laraveleloquentvideoyoutubevimeovideosvkdailymotionrutube

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vhar-laravel-videos/health.svg)

```
[![Health](https://phpackages.com/badges/vhar-laravel-videos/health.svg)](https://phpackages.com/packages/vhar-laravel-videos)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.9M113](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k35.7M52](/packages/kirschbaum-development-eloquent-power-joins)[illuminate/database

The Illuminate Database package.

2.8k55.8M13.4k](/packages/illuminate-database)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.6k13.4M357](/packages/spatie-laravel-sluggable)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.3M27](/packages/yajra-laravel-oci8)[lemaur/eloquent-publishing

218.5k1](/packages/lemaur-eloquent-publishing)

PHPackages © 2026

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