survos / media-bundle
Manage media without direct relationships
Fund package maintenance!
Requires
- php: ^8.4
- doctrine/dbal: ^4.3.2
- doctrine/doctrine-bundle: ^2.7|^3.0
- mperonnet/imgproxy-php: ^1.0
- museado/data-bundle: ^1.0
- onliner/imgproxy-php: ^0.2
- survos/import-bundle: ^1.0
- symfony/config: ^7.3||^8.0
- symfony/dependency-injection: ^7.3||^8.0
- symfony/http-kernel: ^7.3||^8.0
- twig/twig: ^3.4
Requires (Dev)
- nyholm/psr7: ^1.8
- openai-php/client: ^0.16.1
- phpstan/phpstan: ^2.0
- symfony/browser-kit: ^7.3||^8.0
- symfony/framework-bundle: ^7.3||^8.0
- symfony/http-client: ^7.3||^8.0
- symfony/phpunit-bridge: ^7.3||^8.0
- symfony/twig-bundle: ^7.3||^8.0
- symfony/var-dumper: ^7.3||^8.0
Suggests
- symfony/ai-platform: Required for #[With] JSON Schema constraints on MediaSyncItem properties
- dev-main
- 2.0.138
- 2.0.137
- 2.0.136
- 2.0.135
- 2.0.134
- 2.0.133
- 2.0.132
- 2.0.131
- 2.0.130
- 2.0.129
- 2.0.128
- 2.0.127
- 2.0.126
- 2.0.125
- 2.0.124
- 2.0.123
- 2.0.122
- 2.0.121
- 2.0.120
- 2.0.119
- 2.0.117
- 2.0.116
- 2.0.115
- 2.0.114
- 2.0.113
- 2.0.112
- 2.0.111
- 2.0.110
- 2.0.109
- 2.0.108
- 2.0.107
- 2.0.106
- 2.0.105
- 2.0.104
- 2.0.83
- 2.0.82
- 2.0.81
- 2.0.80
- 2.0.79
- 2.0.78
- 2.0.77
- 2.0.76
- 2.0.75
- 2.0.74
- 2.0.73
- 2.0.72
- 2.0.71
- 2.0.70
- 2.0.69
- 2.0.68
- 2.0.67
- 2.0.66
- 2.0.65
- 2.0.64
- 2.0.63
- 2.0.62
- 2.0.61
- 2.0.60
- 2.0.59
- 2.0.58
- 2.0.57
- 2.0.56
- 2.0.55
- 2.0.54
- 2.0.53
- 2.0.51
- 2.0.50
- 2.0.49
- 2.0.48
- 2.0.47
- 2.0.46
- 2.0.45
- 2.0.44
- 2.0.43
- 2.0.42
- 2.0.41
- 2.0.40
- 2.0.39
- 2.0.38
- 2.0.37
- 2.0.36
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
This package is auto-updated.
Last update: 2026-03-16 12:49:54 UTC
README
SurvosMediaBundle provides a deterministic, URL‑centric media registry for Symfony applications.
It is intentionally not a media processor. Instead, it:
- Registers media references (URLs or local files)
- Assigns deterministic IDs derived from URLs
- Stores application‑local media metadata
- Syncs with a centralized media server (future step)
- Generates thumbnail URLs via imgproxy‑style patterns (future step)
This mirrors the relationship between babel‑bundle and lingua‑server:
- Applications own their media tables
- A central service owns the binaries and heavy processing
Core Concept: Deterministic Media IDs
Every media item has a stable, deterministic ID derived from its URL.
use Survos\MediaBundle\Service\MediaRegistry; $id = MediaRegistry::idFromUrl('https://example.com/image.jpg');
The algorithm:
- Base64‑encodes the URL
- Converts it to URL‑safe base64
- Removes padding
This is the same philosophy used by imgproxy.
Why this matters
- No database lookups to resolve URLs
- IDs are reversible
- Same URL → same ID across apps
- Safe primary key for Meilisearch
Registering Media
The primary entry point is MediaRegistry.
foreach ($data->images as $imageUrl) { $media = $mediaRegistry->ensureMedia($imageUrl); }
Behavior
- Defaults to
Photo - No duplicate URLs
- Bulk‑safe (
flush: false) - No network calls
Local files are also supported:
$media = $mediaRegistry->ensureMedia($uploadedFile);
Local files are assigned a temporary local:// URL until synced.
Probing Mediary (Polling Fallback)
When webhook callbacks are unavailable (for example, local dev tunnels are down), poll mediary directly via the bundle service.
use Survos\MediaBundle\Service\MediaBatchDispatcher; $result = $mediaBatchDispatcher->dispatch('museum', [$url], [ 'callback_url' => 'https://my-app.example/webhook/media', ]); $assetId = $result->media[0]->mediaKey; $probe = $mediaBatchDispatcher->probe($assetId); if ($probe->isComplete()) { // use $probe->meta / $probe->context / $probe->ocr / $probe->ai }
Available methods:
probe(string $assetId): MediaProbeResult→ callsGET /fetch/media/{id}probeMany(array $assetIds): array<MediaProbeResult>→ callsPOST /fetch/media/by-ids
Probe payload includes current workflow state (marking), variants/thumb URLs, metadata, and any OCR/AI context that has been written so far.
CLI helper:
bin/console media:probe 5c4e0c2d6f8a1b9e bin/console media:probe "https://example.org/image.jpg" bin/console media:probe --url "upload://sha256/abcd..."
What This Bundle Does Not Do
- Download media
- Resize images
- Cache thumbnails
- Perform OCR, tagging, or EXIF extraction
Those responsibilities belong to the media server and imgproxy.
Status
This bundle is intentionally minimal and evolving.
Next steps include:
media:synccommand- Provider detection (YouTube, Flickr, etc.)
- Thumbnail URL generation helpers