PHPackages                             webwizardsusa/laravel-oembed - 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. webwizardsusa/laravel-oembed

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

webwizardsusa/laravel-oembed
============================

Generate external embed code from a URL via the oembed protocol

0.1.0(1y ago)41081MITPHPPHP ^8.2

Since Nov 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/webwizardsusa/laravel-oembed)[ Packagist](https://packagist.org/packages/webwizardsusa/laravel-oembed)[ Docs](https://github.com/webwizardsusa/laravel-oembed)[ RSS](/packages/webwizardsusa-laravel-oembed/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

OEmbed For Laravel
==================

[](#oembed-for-laravel)

**(NOTE: This package is in early development.)**

This package allows you to retrieve embed information for URLs from various oembed providers, similar to Wordpress. Out of the box, we support the following websites:

- Amazon
- Bluesky
- Dailymotion
- Flickr
- Pinterest
- Scribd
- Sound Cloud
- Spotify
- Tiktok
- Tumbler
- Twitter
- Vimeo
- Youtube

Providers can be disabled inside the configuration. Adding of additional providers is a rather simple process. See below.

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

[](#installation)

You can install the package via composer:

```
composer require webwizardsusa/laravel-oembed

```

#### Responsive Iframe CSS

[](#responsive-iframe-css)

This package makes responsive IFrames possible. To enabled them on your site, you need to add the following CSS to your site:

```
.oembed-responsive-container {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
}

.oembed-responsive-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
```

#### Configuration publishing

[](#configuration-publishing)

If you wish to alter the list of providers, or adjust any other configuration values, then you can publish the configuration with:

```
php artisan vendor:publish --tag=oembed-config
```

The following configuration values are available:

ConfigEnvDefaultDescriptionproviders-arrayAn array of enabled provider classescache.enabledOEMBED\_ENABLE\_CACHEtrueEnables caching of responsescache.ttlOEMBED\_URL\_CACHE\_TTL10080The number of minutes to cache successful responsescache.invalid\_ttlOEMBED\_INVALID\_URL\_CACHE\_TTL10The number of minutes to cache invalid responsescachek.key\_prefixOEMBED\_CACHE\_PREFIXoembed\_url\_A prefix to attach to the key of all cached itemscache.driverOEMBED\_CACHE\_DRIVERnullThe cache driver to useUsage
-----

[](#usage)

Usage is very simple. Just utilize the OEmbed service to retrieve information about a URL.

```
app(\Webwizardsusa\OEmbed\OEmbed::class)->fromUrl('https://www.youtube.com/watch?v=gaeV9Jp3Uhk')->toArray()
```

Running that will result in the following output:

```
{
  "url": "https://www.youtube.com/watch?v=gaeV9Jp3Uhk",
  "provider": "youtube",
  "embed_code": "",
  "raw": {
    "title": "Filament Plugin: Relation Manager as Table Modal",
    "author_name": "Filament Daily",
    "author_url": "https://www.youtube.com/@FilamentDaily",
    "type": "video",
    "height": 150,
    "width": 200,
    "version": "1.0",
    "provider_name": "YouTube",
    "provider_url": "https://www.youtube.com/",
    "thumbnail_height": 360,
    "thumbnail_width": 480,
    "thumbnail_url": "https://i.ytimg.com/vi/gaeV9Jp3Uhk/hqdefault.jpg",
    "html": ""
  },
  "width": 200,
  "height": 150,
  "retrieved_at": "2024-11-20T11:30:34.528865Z"
}
```

The fromUrl() method will return a OEmbedResponse if successful, or null if not successful.

You can also render the embed from the OEmbedResponse by calling the render() method. Rending is done through views. Each provider decides which view to use, html, iframe or responsive-iframe.

Providers
---------

[](#providers)

For the most part providers are very simple classes:

```
class YoutubeProvider extends AbstractOembedProvider
{

    protected array $regexes = [
        '#https?://((m|www)\.)?youtube\.com/watch.*#i',
        '#https?://((m|www)\.)?youtube\.com/playlist.*#i',
        '#https?://((m|www)\.)?youtube\.com/shorts/*#i',
        '#https?://((m|www)\.)?youtube\.com/live/*#i',
        '#https?://youtu\.be/.*#i',
    ];
    protected string $oembedUrl = 'https://www.youtube.com/oembed';

    public function name(): string
    {
        return 'youtube';
    }
}
```

A simple array of regex patterns to match the URL, then the url of that services oembed service. While this works for a majority of the providers, sometimes you may need to extend how information is retrieved. To do that, you can override pull() on the provider class:

```
   public function pull(OEmbedUrl $url, $apiUrl):OEmbedResponse
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

This package is developed by [WebWizardsUSA](https://webwizardsusa.com/).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance40

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

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

535d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a47419a2a5ee39e5e903f8b198ac4b9e3f8a0697af50d1f088847b35bdd143a?d=identicon)[webwizardsusa](/maintainers/webwizardsusa)

---

Top Contributors

[![jholly-wwu](https://avatars.githubusercontent.com/u/121579147?v=4)](https://github.com/jholly-wwu "jholly-wwu (2 commits)")

---

Tags

laraveloembedlaravel-oembedwebwizardsusa

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/webwizardsusa-laravel-oembed/health.svg)

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

###  Alternatives

[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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