- 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.