survos / media-topics-bundle
IPTC Media Topics in a Symfony app: the vocabulary as a service, plus console commands and agent tools to browse and search it
Package info
github.com/survos/media-topics-bundle
Type:symfony-bundle
pkg:composer/survos/media-topics-bundle
Fund package maintenance!
Requires
- php: ^8.5
- survos/kit-bundle: ^2.5
- survos/media-topics: ^2.34
- symfony/config: ^8.1
- symfony/console: ^8.1
- symfony/dependency-injection: ^8.1
- symfony/framework-bundle: ^8.1
- symfony/http-kernel: ^8.1
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^13.0
- survos/command-bundle: ^2.34
- symfony/http-client: ^8.1
Suggests
- survos/command-bundle: Exposes the browse and search commands as MCP agent tools.
- symfony/http-client: Needed by media-topics:download to fetch a newer release from IPTC.
Provides
None
Conflicts
None
Replaces
None
README
IPTC Media Topics and IPTC Genre in a Symfony app: the
vocabularies as autowirable services, and console commands to browse and search it. The vocabulary itself, and
everything you can do with it, is in survos/media-topics.
composer require survos/media-topics-bundle
Service
use Survos\MediaTopics\Genres; use Survos\MediaTopics\MediaTopics; final class ArticleController { public function __construct( private readonly MediaTopics $topics, private readonly Genres $genres, ) {} }
Commands
bin/console media-topics:show # the 17 top-level topics bin/console media-topics:show medtop:20000479 # one topic: path, definition, mappings, children bin/console media-topics:show 20000479 --locale=es bin/console media-topics:search "healthcare policy" bin/console media-topics:genres # the IPTC Genres: Obituary, Review, Opinion, ... bin/console media-topics:genres opinion bin/console media-topics:download var/mediatopic.json bin/console media-topics:download var/genre.json --genre
show, search and genres take --format=json, and are public read-only agent tools when
survos/command-bundle is installed.
download fetches the current release from IPTC (needs symfony/http-client) and checks that it
parses before replacing the file. Point the bundle at it to use it:
# config/packages/survos_media_topics.yaml survos_media_topics: file: '%kernel.project_dir%/var/mediatopic.json' # default: the release pinned in survos/media-topics # genre_file: '%kernel.project_dir%/var/genre.json' locale: en-GB # what the commands show when no --locale is given
Loading topics into your own table
An app that keeps topics in Doctrine (for a tree widget, or foreign keys from articles) can fill its entity from the service. Topics come parents-first, so each parent already exists:
foreach ($topics->all(includeRetired: true) as $topic) { $row = $em->find(Topic::class, $topic->id) ?? new Topic($topic->id); $row->setName($topic->label())->setDescription($topic->definition()); $row->setParent($topic->parentId ? $em->getReference(Topic::class, $topic->parentId) : null); $em->persist($row); } $em->flush();
Include retired topics so existing references keep resolving.
License
MIT. The vocabulary is © IPTC, licensed CC BY 4.0; credit IPTC in applications that embed it.