Transform URLs into rich embedded content for Laravel applications. Automatically detects and renders embeds for YouTube, Vimeo, GitHub Gists, and generates beautiful link preview cards using OpenGraph metadata.
Warning
This package is currently under active development, and we have not yet released a major version. Once a 0.* version has been tagged, we strongly recommend locking your application to a specific working version because we might make breaking changes even in patch releases until we've tagged 1.0.
- π₯ Video Embeds: Native players for YouTube and Vimeo with responsive aspect ratios
- π» Code Embeds: GitHub Gist embedding with syntax highlighting
- π OpenGraph Cards: Beautiful link previews with title, image, and description
- π Generic Fallback: Smart metadata extraction for any URL
- β‘ Caching: Configurable metadata caching to minimize HTTP requests
- π¨ Flux UI: Built with Flux UI Pro components (customizable)
- β Validation: Laravel validation rule for embeddable URLs
composer require artisan-build/embeddable-linksPublish the configuration file (optional):
php artisan vendor:publish --tag=embeddable-links-configEMBEDDABLE_LINKS_CACHE_ENABLED=true
EMBEDDABLE_LINKS_CACHE_TTL=86400 # 24 hours in seconds
EMBEDDABLE_LINKS_HTTP_TIMEOUT=5 # HTTP request timeout in seconds
EMBEDDABLE_LINKS_ASPECT_RATIO=16/9<x-embeddable-links-embed url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" /><x-embeddable-links-embed
url="https://vimeo.com/123456789"
aspect-ratio="4/3"
/><x-embeddable-links-embed
url="https://example.com/article"
:cache="false"
/>By default, OpenGraph and generic link cards open in a new tab (target="_blank"). You can override this:
<x-embeddable-links-embed
url="https://example.com/article"
target="_self"
/>YouTube:
<x-embeddable-links-embed url="https://www.youtube.com/watch?v=VIDEO_ID" />
<x-embeddable-links-embed url="https://youtu.be/VIDEO_ID" />Vimeo:
<x-embeddable-links-embed url="https://vimeo.com/VIDEO_ID" />GitHub Gist:
<x-embeddable-links-embed url="https://gist.github.com/username/GIST_ID" />Any URL with OpenGraph:
<x-embeddable-links-embed url="https://laravel.com/docs" />Use the EmbeddableUrl validation rule:
use ArtisanBuild\EmbeddableLinks\Rules\EmbeddableUrl;
$request->validate([
'url' => ['required', 'url', new EmbeddableUrl],
]);Restrict to specific services:
$request->validate([
'url' => ['required', 'url', new EmbeddableUrl(['youtube', 'vimeo'])],
]);use ArtisanBuild\EmbeddableLinks\Services\EmbedManager;
$manager = app(EmbedManager::class);
$html = $manager->embed('https://www.youtube.com/watch?v=dQw4w9WgXcQ');php artisan vendor:publish --tag=embeddable-links-viewsViews will be published to resources/views/vendor/embeddable-links/embeds/:
youtube.blade.phpvimeo.blade.phpgithub-gist.blade.phpopengraph.blade.phpgeneric.blade.php
Visit /embeddable-links-demo to see all embed types in action (development only).
composer test
composer test-coveragecomposer lint # Fix code style
composer stan # Run static analysis
composer ready # Run all checks- URL Detection: Parses URLs to identify service type (YouTube, Vimeo, Gist, or generic)
- Metadata Fetching: For generic URLs, fetches OpenGraph and HTML metadata
- Caching: Stores metadata in Laravel cache (default: 24 hours)
- Rendering: Uses service-specific Blade templates with Flux UI components
- PHP 8.3+
- Laravel 11.0+
- Flux UI Pro (for default card styles)
This package is part of our internal toolkit and is optimized for our own purposes. We do not accept issues or PRs in this repository.
The MIT License (MIT). Please see License File for more information.
