franzose/closure-table
Closure table implementation for Laravel that turns flat tables into efficient hierarchical trees. Query ancestors and descendants in one call, move nodes without rebuilding the tree, and keep parent-child relationships fast, simple, and scalable.
Architecture fit
ancestor/descendant/depth table) layered over an existing adjacency-list parent_id column — the classic hybrid that keeps simple parent lookups cheap while making descendant/ancestor queries a single indexed join.descendants, ancestors, children, parent) plus tree-mutating methods (make child of / sibling of / move).Integration feasibility
composer.json constraints against the target Laravel version (11/12) and PHP 8.2+.Technical risk
Key questions
parent_id tree?Stack fit
ON DELETE semantics, and lock behavior differ).parent_id on the entity table for cheap parent lookups and let the closure table serve subtree queries.Migration path
parent_id; do not remove any legacy columns.Compatibility
(ancestor, depth) and (descendant) for the query shapes actually used; default migrations may need tuning for large tables.Sequencing
parent_id remains authoritative.Maintenance
parent_id and alerting on drift.Support
Scaling
Failure modes
Ramp-up
parent_id") and the rule that hierarchy mutations go through the model. This single norm prevents most incidents.Recommendation signal: worth a scoped pilot if subtree queries are a demonstrated performance or complexity problem and the hierarchy is read-heavy with shallow-to-moderate depth. If hierarchy writes are frequent or depth is unbounded, evaluate a materialized-path or nested-set alternative — the operational burden here lands on write-time integrity, which is the hardest thing to monitor.
How can I help you explore Laravel packages today?