becklyn/video-platforms
Symfony bundle providing helpers to parse and normalize video URLs (YouTube/Vimeo etc.), serialize/store as “platform@id” or arrays, validate via constraints, and integrate with entities and forms using a VideoUrlType.
VideoUrlType for forms, Doctrine annotations).VideoPlatformInterface, which could be adapted for Laravel with minimal effort (e.g., via service providers or package traits).VideoUrlParser facade wrapping the Symfony parser).<platform>@<id> format is simple and portable; Laravel’s Eloquent or database columns (e.g., json or string) can store this natively.@VideoUrl constraint would need replacement with Laravel’s Form Request validation or custom validation rules (e.g., VideoUrl rule in Laravel’s Illuminate\Validation).VideoUrlType would require a Laravel equivalent (e.g., a Form Request or custom Form Component).symfony/options-resolver, symfony/validator, and symfony/form. Laravel could use standalone Symfony components (e.g., symfony/validator for validation) or replace them with Laravel equivalents (e.g., laravel/framework's validation).json columns or Laravel’s json casting.VideoUrlType or Doctrine annotations cannot be directly used in Laravel without significant refactoring.vimeo@123 input).VideoUrlParserAdapter).VideoUrlRule) that replicates the Symfony constraint’s logic.symfony/validator) be managed in a Laravel context?symfony/validator, symfony/options-resolver) without pulling in the full Symfony framework.symfony/validator, symfony/options-resolver) via Composer.// app/Services/VideoUrlParserAdapter.php
class VideoUrlParserAdapter
{
public function parse(string $url): array
{
$parser = new \Becklyn\VideoPlatforms\Parser\VideoUrlParser();
$video = $parser->parse($url);
return $video->toArray();
}
}
// app/Rules/VideoUrl.php
class VideoUrl implements Rule
{
public function passes($attribute, $value)
{
// Use the Symfony validator or replicate its logic
return true/false;
}
}
// app/Http/Livewire/VideoUrlInput.php
class VideoUrlInput extends Component
{
public $videoUrl;
public function updatedVideoUrl()
{
$this->validate(['videoUrl' => ['required', new VideoUrl]]);
}
}
Json or String casting for the video data:
// app/Models/Post.php
protected $casts = [
'video' => 'array', // or 'string' for serialized format
];
Video objects:
public function getVideoUrlAttribute($value)
{
return $value ? (new \Becklyn\VideoPlatforms\Video\Video($value['platform'], $value['id'])) : null;
}
VideoUrlType) require rewriting for Laravel.<platform>@<id> serialization format in Laravel models.composer require symfony/validator:^6.0 explicitly.VideoPlatformInterface).How can I help you explore Laravel packages today?