Weave Code
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 Package

aliziodev/laravel-taxonomy

Flexible Laravel package for managing taxonomies, categories, tags, and hierarchical trees. Includes nested-set support for fast hierarchy queries, metadata, bulk operations, caching, and custom taxonomy types. Compatible with Laravel 11+.

View on GitHub
Deep Wiki
Context7
v2.10.0

2.10.0 (2026-04-06)

Features

  • add type-specific taxonomy management methods to HasTaxonomy trait with supporting tests (7914b53)
v2.9.0

2.9.0 (2026-03-30)

Features

  • implement core taxonomy package with nested set support and comprehensive test suite (df9503a)
  • implement core taxonomy system including models, traits, commands, and comprehensive test suite (e1e7295)
v2.8.0

2.8.0 (2025-11-24)

Bug Fixes

  • database: modify unique constraint to exclude soft-deleted records (3097332)

Features

  • model: handle slug conflicts and cache clearing on restore (d0035cc)
  • taxonomy: add slug handling options for soft-deleted records (0e22f5d)
v2.7.0

2.7.0 (2025-11-14)

Features

  • migrations: add configurable migration loading for taxonomy (69d8cdc)

Performance Improvements

  • TaxonomyManager: improve cache invalidation strategy (54ccbe6)
v2.6.1

2.6.1 (2025-10-10)

Bug Fixes

  • database: use dynamic table names for taxonomy foreign keys #10 (2908957)
v2.6.0

2.6.0 (2025-09-02)

Features

  • taxonomy: add type-specific operations and query scopes (20cf611)
  • taxonomy: add type-specific taxonomy relationship methods (ee31d44)
v2.5.0

2.5.0 (2025-07-22)

Features

  • refactor to configurable model and merged PR #8 (#9) (409cbe7)
v2.4.8

2.4.8 (2025-07-15)

Bug Fixes

  • taxonomies: relation return model from config (#7) (5c9b85e)
v2.4.7

2.4.7 (2025-07-03)

Bug Fixes

  • ci: resolve composer dependency management issues in workflows (3e46e8d)
v2.4.6

2.4.6 (2025-07-03)

Bug Fixes

  • workflows: remove invalid --prefer-stable flag from composer install (4b7a17d)
v2.4.5

2.4.5 (2025-07-03)

Bug Fixes

  • workflows: prevent orchestra/testbench dependency placement issues (8b5e7e7)
v2.4.4

2.4.4 (2025-07-03)

Bug Fixes

  • composer: move again orchestra/testbench to require-dev (2fc16b0)
  • release: remove composer.json from semantic-release assets (8f3b2db)
v2.4.3

2.4.3 (2025-07-03)

Bug Fixes

  • ci: install orchestra/testbench as dev dependency in all workflows (4c52711)
v2.4.2

2.4.2 (2025-07-03)

Bug Fixes

  • composer: move orchestra/testbench to require-dev section (dc5a1a7)
v2.4.1

2.4.1 (2025-07-03)

Bug Fixes

  • taxonomy: include type in DuplicateSlugException for better error context (67cdd43)
v2.4.0

2.4.0 (2025-07-03)

Bug Fixes

  • Taxonomy: include type in DuplicateSlugException for better error context (6665b4e)

Features

  • exceptions: add type context to DuplicateSlugException for better debugging (defd29b)
v2.3.0

2.3.0 (2025-07-03)

โš  BREAKING CHANGES

  • Composite Unique Slugs: Implementation of composite unique slug system for taxonomies that changes how slug uniqueness is handled. Previously slugs only needed to be globally unique, now uniqueness is determined by the combination of slug, type, and parent_id. This change requires database migration and may affect code that relies on global slug uniqueness assumptions.

Features

  • Composite Unique Slugs for Taxonomies (c7c6d58)
    • Added composite unique constraint on slug, type, and parent_id columns
    • Allows same slug for different taxonomy types or different parents
    • Improves flexibility in taxonomy hierarchy management
    • Provides automatic migration to update database structure
    • Adds validation to prevent slug duplication within the same context

Migration Guide

To upgrade from v2.2.1 to v2.3.0:

  1. Backup Database: Ensure you backup your database before upgrading
  2. Update Package: Run composer update aliziodev/laravel-taxonomy
  3. Create Migration: Generate migration file for database schema changes
  4. Handle Conflicts: Check and resolve any existing slug conflicts across different types
  5. Run Migration: Execute the migration to update database constraints
  6. Review Code: Update any code that relies on global slug uniqueness
  7. Test Thoroughly: Perform comprehensive testing on taxonomy features

Technical Details

This change affects:

  • Database Schema: Addition of composite unique constraint
  • Model Validation: Updated validation rules for slugs
  • Query Logic: Adjustments to queries that depend on slug uniqueness
  • API Behavior: Changes in API behavior for handling duplicate slugs

For complete upgrade information, please refer to the UPGRADE.md file.

v2.2.1

Bug Fixes

v2.2.0

2.2.0 (2025-06-17)

Features

  • HasTaxonomy: add taxonomy scopes for filtering models (5cc5a78)
  • Taxonomy: add getSiblings method to retrieve same-level taxonomies (4756c1a)
v2.1.0

2.1.0 (2025-06-17)

Features

  • implement automated changelog system (0c8c6c0)
v2.0.2

๐Ÿš€ Major Features Added

Nested Set Model Implementation

  • Added complete Nested Set Model support for hierarchical data management
  • Implemented automatic left/right boundary calculation (lft, rgt, depth fields)
  • Added efficient tree traversal methods for ancestors, descendants, and siblings
  • Integrated automatic nested set maintenance on create, update, and delete operations

Performance Optimizations

  • Added bulk operations support for large-scale taxonomy management
  • Implemented efficient tree rebuilding with rebuildNestedSet() method
  • Added performance monitoring and benchmarking capabilities
  • Optimized database queries using nested set boundaries instead of recursive queries

Advanced Tree Operations

  • Added moveToParent() method for efficient node repositioning
  • Implemented cascade delete with orphan prevention
  • Added tree validation and integrity checking
  • Support for concurrent operations with race condition handling

Console Commands

  • Added taxonomy:rebuild-nested-set command for rebuilding nested set values
  • Enhanced taxonomy:install command with better error handling

๐Ÿ”ง Technical Improvements

Database Schema Enhancements

-- Added nested set fields to taxonomies table
ALTER TABLE taxonomies ADD COLUMN lft INTEGER;
ALTER TABLE taxonomies ADD COLUMN rgt INTEGER;
ALTER TABLE taxonomies ADD COLUMN depth INTEGER DEFAULT 0;

-- Added indexes for performance
CREATE INDEX idx_taxonomies_nested_set ON taxonomies(type, lft, rgt);
CREATE INDEX idx_taxonomies_parent ON taxonomies(parent_id);

Model Enhancements

  • Enhanced Taxonomy model with nested set methods:
    • getAncestors() - Get all parent nodes
    • getDescendants() - Get all child nodes
    • getSiblings() - Get nodes at same level
    • getNestedTree() - Get complete tree structure
    • isAncestorOf() - Check parent-child relationship
    • isDescendantOf() - Check child-parent relationship

Service Layer Improvements

  • Added TaxonomyManager service for complex operations
  • Implemented transaction-safe operations for data integrity
  • Added batch processing capabilities for large datasets
  • Enhanced error handling with custom exceptions

๐Ÿงช Testing Infrastructure

Comprehensive Test Suite

  • Added ExtremeTaxonomyTest for edge cases and large datasets
  • Added TaxonomyPerformanceTest for performance benchmarking
  • Added TaxonomyConcurrencyTest for race condition testing
  • Added NestedSetTest for nested set specific operations

Performance Test Coverage

  • Move operation efficiency testing with time assertions
  • Descendants retrieval performance for various tree sizes
  • Delete operations with cascade and orphan prevention
  • Memory usage monitoring for large operations
  • Concurrent operation handling with database transactions

๐Ÿ“Š Performance Metrics

Before Nested Set (v1.x)

  • Tree traversal: O(n) recursive queries
  • Ancestor retrieval: Multiple database hits
  • Move operations: Expensive parent_id updates
  • Large trees: Performance degradation

After Nested Set (v2.0)

  • Tree traversal: O(1) single query with boundaries
  • Ancestor retrieval: Single query with lft/rgt comparison
  • Move operations: Efficient boundary recalculation
  • Large trees: Consistent performance up to 10,000+ nodes

๐Ÿ”„ Migration Guide

Database Migration

# Run the migration to add nested set fields
php artisan migrate

# Rebuild nested set values for existing data
php artisan taxonomy:rebuild-nested-set

# Rebuild specific taxonomy type
php artisan taxonomy:rebuild-nested-set category

# Force rebuild without confirmation
php artisan taxonomy:rebuild-nested-set --force

Code Updates

// Old way (v1.x)
$children = $taxonomy->children;
$ancestors = $this->getAncestorsRecursively($taxonomy);

// New way (v2.0)
$children = $taxonomy->getDescendants();
$ancestors = $taxonomy->getAncestors();

โš ๏ธ Breaking Changes

  • Database schema changes require migration
  • Some method signatures changed for consistency
  • Performance test thresholds may need adjustment for different environments
  • Soft delete behavior modified for nested set integrity

๐Ÿ› Bug Fixes

  • Fixed race conditions in concurrent move operations
  • Resolved orphan node issues in delete operations
  • Fixed nested set boundary corruption in edge cases
  • Corrected performance test assertions for realistic expectations

๐Ÿ“š Documentation

  • Added comprehensive API documentation for all nested set methods
  • Created performance benchmarking guide with optimization tips
  • Added migration guide for upgrading from v1.x
  • Enhanced README with nested set usage examples

v2.0.1

๐Ÿš€ Major Features Added

Nested Set Model Implementation

  • Added complete Nested Set Model support for hierarchical data management
  • Implemented automatic left/right boundary calculation (lft, rgt, depth fields)
  • Added efficient tree traversal methods for ancestors, descendants, and siblings
  • Integrated automatic nested set maintenance on create, update, and delete operations

Performance Optimizations

  • Added bulk operations support for large-scale taxonomy management
  • Implemented efficient tree rebuilding with rebuildNestedSet() method
  • Added performance monitoring and benchmarking capabilities
  • Optimized database queries using nested set boundaries instead of recursive queries

Advanced Tree Operations

  • Added moveToParent() method for efficient node repositioning
  • Implemented cascade delete with orphan prevention
  • Added tree validation and integrity checking
  • Support for concurrent operations with race condition handling

Console Commands

  • Added taxonomy:rebuild-nested-set command for rebuilding nested set values
  • Enhanced taxonomy:install command with better error handling

๐Ÿ”ง Technical Improvements

Database Schema Enhancements

-- Added nested set fields to taxonomies table
ALTER TABLE taxonomies ADD COLUMN lft INTEGER;
ALTER TABLE taxonomies ADD COLUMN rgt INTEGER;
ALTER TABLE taxonomies ADD COLUMN depth INTEGER DEFAULT 0;

-- Added indexes for performance
CREATE INDEX idx_taxonomies_nested_set ON taxonomies(type, lft, rgt);
CREATE INDEX idx_taxonomies_parent ON taxonomies(parent_id);

Model Enhancements

  • Enhanced Taxonomy model with nested set methods:
    • getAncestors() - Get all parent nodes
    • getDescendants() - Get all child nodes
    • getSiblings() - Get nodes at same level
    • getNestedTree() - Get complete tree structure
    • isAncestorOf() - Check parent-child relationship
    • isDescendantOf() - Check child-parent relationship

Service Layer Improvements

  • Added TaxonomyManager service for complex operations
  • Implemented transaction-safe operations for data integrity
  • Added batch processing capabilities for large datasets
  • Enhanced error handling with custom exceptions

๐Ÿงช Testing Infrastructure

Comprehensive Test Suite

  • Added ExtremeTaxonomyTest for edge cases and large datasets
  • Added TaxonomyPerformanceTest for performance benchmarking
  • Added TaxonomyConcurrencyTest for race condition testing
  • Added NestedSetTest for nested set specific operations

Performance Test Coverage

  • Move operation efficiency testing with time assertions
  • Descendants retrieval performance for various tree sizes
  • Delete operations with cascade and orphan prevention
  • Memory usage monitoring for large operations
  • Concurrent operation handling with database transactions

๐Ÿ“Š Performance Metrics

Before Nested Set (v1.x)

  • Tree traversal: O(n) recursive queries
  • Ancestor retrieval: Multiple database hits
  • Move operations: Expensive parent_id updates
  • Large trees: Performance degradation

After Nested Set (v2.0)

  • Tree traversal: O(1) single query with boundaries
  • Ancestor retrieval: Single query with lft/rgt comparison
  • Move operations: Efficient boundary recalculation
  • Large trees: Consistent performance up to 10,000+ nodes

๐Ÿ”„ Migration Guide

Database Migration

# Run the migration to add nested set fields
php artisan migrate

# Rebuild nested set values for existing data
php artisan taxonomy:rebuild-nested-set

# Rebuild specific taxonomy type
php artisan taxonomy:rebuild-nested-set category

# Force rebuild without confirmation
php artisan taxonomy:rebuild-nested-set --force

Code Updates

// Old way (v1.x)
$children = $taxonomy->children;
$ancestors = $this->getAncestorsRecursively($taxonomy);

// New way (v2.0)
$children = $taxonomy->getDescendants();
$ancestors = $taxonomy->getAncestors();

โš ๏ธ Breaking Changes

  • Database schema changes require migration
  • Some method signatures changed for consistency
  • Performance test thresholds may need adjustment for different environments
  • Soft delete behavior modified for nested set integrity

๐Ÿ› Bug Fixes

  • Fixed race conditions in concurrent move operations
  • Resolved orphan node issues in delete operations
  • Fixed nested set boundary corruption in edge cases
  • Corrected performance test assertions for realistic expectations

๐Ÿ“š Documentation

  • Added comprehensive API documentation for all nested set methods
  • Created performance benchmarking guide with optimization tips
  • Added migration guide for upgrading from v1.x
  • Enhanced README with nested set usage examples

v2.0.0

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[2.0.0] - 2025-05-31

๐Ÿš€ Major Features Added

Nested Set Model Implementation

  • Added complete Nested Set Model support for hierarchical data management
  • Implemented automatic left/right boundary calculation (lft, rgt, depth fields)
  • Added efficient tree traversal methods for ancestors, descendants, and siblings
  • Integrated automatic nested set maintenance on create, update, and delete operations

Performance Optimizations

  • Added bulk operations support for large-scale taxonomy management
  • Implemented efficient tree rebuilding with rebuildNestedSet() method
  • Added performance monitoring and benchmarking capabilities
  • Optimized database queries using nested set boundaries instead of recursive queries

Advanced Tree Operations

  • Added moveToParent() method for efficient node repositioning
  • Implemented cascade delete with orphan prevention
  • Added tree validation and integrity checking
  • Support for concurrent operations with race condition handling

Console Commands

  • Added taxonomy:rebuild-nested-set command for rebuilding nested set values
  • Enhanced taxonomy:install command with better error handling

๐Ÿ”ง Technical Improvements

Database Schema Enhancements

-- Added nested set fields to taxonomies table
ALTER TABLE taxonomies ADD COLUMN lft INTEGER;
ALTER TABLE taxonomies ADD COLUMN rgt INTEGER;
ALTER TABLE taxonomies ADD COLUMN depth INTEGER DEFAULT 0;

-- Added indexes for performance
CREATE INDEX idx_taxonomies_nested_set ON taxonomies(type, lft, rgt);
CREATE INDEX idx_taxonomies_parent ON taxonomies(parent_id);

Model Enhancements

  • Enhanced Taxonomy model with nested set methods:
    • getAncestors() - Get all parent nodes
    • getDescendants() - Get all child nodes
    • getSiblings() - Get nodes at same level
    • getNestedTree() - Get complete tree structure
    • isAncestorOf() - Check parent-child relationship
    • isDescendantOf() - Check child-parent relationship

Service Layer Improvements

  • Added TaxonomyManager service for complex operations
  • Implemented transaction-safe operations for data integrity
  • Added batch processing capabilities for large datasets
  • Enhanced error handling with custom exceptions

๐Ÿงช Testing Infrastructure

Comprehensive Test Suite

  • Added ExtremeTaxonomyTest for edge cases and large datasets
  • Added TaxonomyPerformanceTest for performance benchmarking
  • Added TaxonomyConcurrencyTest for race condition testing
  • Added NestedSetTest for nested set specific operations

Performance Test Coverage

  • Move operation efficiency testing with time assertions
  • Descendants retrieval performance for various tree sizes
  • Delete operations with cascade and orphan prevention
  • Memory usage monitoring for large operations
  • Concurrent operation handling with database transactions

๐Ÿ“Š Performance Metrics

Before Nested Set (v1.x)

  • Tree traversal: O(n) recursive queries
  • Ancestor retrieval: Multiple database hits
  • Move operations: Expensive parent_id updates
  • Large trees: Performance degradation

After Nested Set (v2.0)

  • Tree traversal: O(1) single query with boundaries
  • Ancestor retrieval: Single query with lft/rgt comparison
  • Move operations: Efficient boundary recalculation
  • Large trees: Consistent performance up to 10,000+ nodes

๐Ÿ”„ Migration Guide

Database Migration

# Run the migration to add nested set fields
php artisan migrate

# Rebuild nested set values for existing data
php artisan taxonomy:rebuild-nested-set

# Rebuild specific taxonomy type
php artisan taxonomy:rebuild-nested-set category

# Force rebuild without confirmation
php artisan taxonomy:rebuild-nested-set --force

Code Updates

// Old way (v1.x)
$children = $taxonomy->children;
$ancestors = $this->getAncestorsRecursively($taxonomy);

// New way (v2.0)
$children = $taxonomy->getDescendants();
$ancestors = $taxonomy->getAncestors();

โš ๏ธ Breaking Changes

  • Database schema changes require migration
  • Some method signatures changed for consistency
  • Performance test thresholds may need adjustment for different environments
  • Soft delete behavior modified for nested set integrity

๐Ÿ› Bug Fixes

  • Fixed race conditions in concurrent move operations
  • Resolved orphan node issues in delete operations
  • Fixed nested set boundary corruption in edge cases
  • Corrected performance test assertions for realistic expectations

๐Ÿ“š Documentation

  • Added comprehensive API documentation for all nested set methods
  • Created performance benchmarking guide with optimization tips
  • Added migration guide for upgrading from v1.x
  • Enhanced README with nested set usage examples
v1.0.0

Laravel Taxonomy Package

Laravel Taxonomy is a powerful and flexible package for managing taxonomies, categories, tags, and hierarchical terms in Laravel applications. It provides a robust solution for organizing content with features like metadata support, ordering capabilities, and efficient caching mechanisms.

Overview

This package is ideal for:

  • E-commerce category management
  • Blog taxonomies
  • Content organization
  • Product attributes
  • Dynamic navigation
  • Any hierarchical data structure

Key Features

  • Hierarchical Terms: Create parent-child relationships between terms
  • Metadata Support: Store additional data as JSON with each taxonomy
  • Term Ordering: Control the order of terms with sort_order
  • Caching System: Improve performance with built-in caching
  • Polymorphic Relationships: Associate taxonomies with any model
  • Multiple Term Types: Use predefined types (Category, Tag, etc.) or create custom types
  • Bulk Operations: Attach, detach, sync, or toggle multiple taxonomies at once
  • Advanced Querying: Filter models by taxonomies with query scopes
  • Tree Structure: Get hierarchical or flat tree representations
  • Pagination Support: Paginate results for better performance
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony