Search by

survos / media-topics-bundle

tacman1123

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!

kbond

Statistics

Installs: 140

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.34.22 2026-09-30 12:30 UTC

This package is auto-updated.

Last update: 2026-09-30 12:54:47 UTC


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.