Skip to main content

Embed Helpers

The embed helpers bundle is a Symfony bundle that helps dealing with platform that allow embedding content (like video platforms).

Installation

composer req 21torr/embed-helpers

Usage

Right now, only the video platforms integration is implemented.

Video Platforms

You can fetch the VideoUrlParser service to parse video URLs and get details about the video:

public function myAction (VideoUrlParser $videoUrlParser)
{
$details = $videoUrlParser->parseVideoUrl("https://www.youtube.com/...");
}

The details include:

$video->id // the video id
$video->platform // the platform where this video is hosted (currently Vimeo and YouTube only)

$details->getEmbedUrl() // will give you the normalized embed URL to use this video in your app

Currently supported video platforms are:

PlatformKey
Vimeovimeo
YouTubeyoutube
YouTube (Shorts)youtube-short

In your PHP code, you should always use the VideoPlatform::* enums.