Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Taxonomy

Laravel Taxonomy Laravel Package

aliziodev/laravel-taxonomy

Manage categories, tags, and any hierarchical structure in Laravel. Terms live in one table, attach to any model via a polymorphic pivot, and nested-set hierarchies keep ancestor and descendant lookups to a single query.

View on GitHub
Deep Wiki
Context7

Laravel Taxonomy gives your Laravel app one system for categories, tags, and any hierarchical structure. Terms live in a single table, attach to any model through a polymorphic pivot, and hierarchies are stored as a nested set — so ancestor and descendant lookups stay a single query instead of recursive loops.

  • One terms table, with types to separate taxonomies
  • Nested-set hierarchies with single-query traversal
  • Polymorphic attachment to any Eloquent model
  • Bulk imports, metadata, caching, and multi-tenancy
  • Query scopes, slug handling, and artisan commands
Frequently asked questions about Laravel Taxonomy
How do I install aliziodev/laravel-taxonomy in a Laravel application?
Run composer require aliziodev/laravel-taxonomy, then run the taxonomy:install command to publish the config file and migrations, and finally run php artisan migrate. The service provider is auto-discovered, so no manual registration is needed. After migrating, add the HasTaxonomy trait to any model you want to categorize or tag.
Which Laravel and PHP versions does laravel-taxonomy support?
The package targets Laravel 11, 12, and 13 and requires PHP 8.2 or newer. That floor means Laravel 10 or PHP 8.1 applications cannot adopt it without upgrading first. Check your composer.json platform constraints before you spend time evaluating it.
How does the nested set hierarchy work in laravel-taxonomy?
Hierarchies are stored as a nested set with left and right bounds, so fetching ancestors or descendants of a term is a single indexed query instead of recursive lookups. The trade-off is writes: every insert or move rewrites the bounds of surrounding rows. That makes it a great fit for read-heavy, rarely edited trees like category menus, and a poor fit for taxonomies that mutate on every request.
How do I attach taxonomies to an Eloquent model?
Add the HasTaxonomy trait to the model, then use the provided relationship methods to attach, sync, or detach terms. Terms are linked through a polymorphic taxonomables pivot, so one taxonomy table serves every model type in your app. The trait is additive and does not change existing model behavior unless you replace a competing taxonomy trait with it.
Can laravel-taxonomy use UUID or ULID primary keys for the polymorphic pivot?
Yes. The morph key type is configurable, so models with numeric, UUID, or ULID keys can all share the same taxonomy store. Verify early that your writes respect Laravel's Relation::enforceMorphMap, because a morph alias mismatch produces silently orphaned pivot rows that are painful to trace later.
Why does findBySlug return the wrong term after upgrading to v2.3.0?
Version 2.3.0 changed slugs to be unique per taxonomy type instead of globally, so the same slug can now exist under more than one type. Lookups that assumed global uniqueness become ambiguous and should pass a type explicitly. Standardize on type-qualified slug lookups from day one and pin the major version.
How do I stop laravel-taxonomy from loading migrations automatically?
Set migrations.autoload to false in the published config, or set the TAXONOMY_AUTOLOAD_MIGRATIONS environment variable to false. This matters in multi-tenant or multi-database setups where migrations must run per tenant rather than globally. Make it a deliberate configuration step in your deployment checklist rather than something you discover in staging.
Is laravel-taxonomy a good alternative to spatie/laravel-tags?
Both store tags through a polymorphic pivot, but laravel-taxonomy adds nested-set hierarchies and typed taxonomies that spatie/laravel-tags does not provide. If you only need flat tags, spatie is the more established choice; if you need category trees and tags from one model, this package covers both. The bigger decision is consolidation, since running two taxonomy systems in parallel is a common failure mode.
Should I filter or sort on the metadata JSON column in laravel-taxonomy?
Treat metadata as an opaque blob for display or storage, not as a queryable dimension. JSON columns are usually unindexed unless you add generated columns or expression indexes, and unreviewed keys drift from your domain model. Anything you expect to filter or sort on should be a first-class column or its own taxonomy type.
Is aliziodev/laravel-taxonomy safe to use in production?
It is a single-maintainer package with modest adoption and little public production evidence, so budget for a bus factor of one. The nested-set invariant also means your write paths own tree integrity, and a bad move can corrupt the hierarchy. Pin the major version, test hierarchy writes thoroughly, and be ready to fork or replace it if maintenance stalls.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style