Skip to content

phil/taxonomy-bundle

alpha

Tags and a translated category tree for any kind of resource, with form types to edit them.

phil/taxonomy-bundle gives a Symfony application tags and a tree of categories. A tag is found or created by its name, whatever its case or accents, then renamed or merged into another. A category has a key, a parent, a position among its siblings, and names and descriptions by language. It moves with its whole branch, never under itself, and merges into another. A resource is tagged and categorized by its kind and identifier, then found again by tag or by a whole branch at once.

It is for an application whose editors sort pages, events or products, and whose visitors browse them by subject in their own language. Two names that differ only by accents or case are one tag, so Jeux de rôle and jeux de role never split a list in two. Merging cleans up duplicates without losing a single assignment.

The bundle stores its tables with Doctrine ORM and refers to resources through phil/resource, so a tag never needs a foreign key to the tagged entity. Slugs and category keys come from phil/slug, or from a named slugger of phil/slug-bundle. TagsType and CategoryType plug into Symfony Form: tags typed as text separated by commas, and a category picked from the indented tree. Each category keeps its path from the root, which finds a whole branch in a single query.

Status

PartState
Tag, Category, CategoryTranslation, Assignment; the repository portImplemented and tested
Taxonomy: tags, categories, the tree, assignments, mergesImplemented and tested
DoctrineTaxonomyRepositoryImplemented and tested
TagsType, CategoryTypeImplemented and tested

Documentation

DocumentWhat it covers
InstallationRequirements, registering, configuration, the tables.
TagsFinding, giving, renaming and merging tags.
CategoriesThe tree, names by language, moving, merging, categorizing.
FormsTagsType and CategoryType.
Extension pointsWhat an application implements, configures, replaces or relies on.
TestingHow the bundle is tested.
ReferenceEvery type of the bundle.

Quick start

$page = ResourceReference::of('page', $page->id);
$taxonomy->setTags($page, ['Jeux', 'soirée']);

$games = $taxonomy->createCategory('games', null, ['fr' => 'Jeux', 'en' => 'Games']);
$taxonomy->categorize($page, [$games]);
$taxonomy->categorizedIn($games);   // the whole branch

Requirements

PHP 8.5 or later with ext-intl and ext-mbstring; Doctrine ORM 3.7; Symfony 8.2's dependency injection, config, form, options resolver and UID; phil/slug 0.1 for slugs and phil/resource 0.1 for resource references.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.