umbrellio/laravel-ltree
Laravel integration for PostgreSQL ltree that brings hierarchical tree data to Eloquent models. Provides migrations, path helpers, and query scopes for ancestors, descendants, and subtree traversal, making tree-structured data easy to store and search.
WITH RECURSIVE) or a custom ltree query builder, then maintaining it. This package is a thin, MIT-licensed adapter — low cost to adopt, low cost to abandon. That asymmetry is the core PM argument.Consider it when:
Look elsewhere when:
kalnoy/nestedset (much larger community, multi-DB) is the conventional comparison; recursive CTEs are the zero-dependency option.parent_id column plus application code is cheaper to reason about and avoids a Postgres-specific lock-in for no measurable gain.Adoption criteria to gate on: confirm Postgres version supports the ltree operators you need, confirm GiST index creation fits your migration/ops workflow, and require a spike proving subtree queries and a re-parent operation against realistic data volume before committing it to the roadmap.
To executives: This is a small, free (MIT) open-source adapter that lets us add hierarchical features — category trees, org structures, nested permissions — without building the data plumbing ourselves. It runs on PostgreSQL, which we already use, and it turns what would normally be recursive application code into a single indexed database query, which means faster pages and less custom code to maintain. The trade-offs are honest: it's a small project with a limited community, so we should pilot it on one feature and keep the integration isolated. Cost to try is low; cost to reverse is low.
To engineering: It's a thin Eloquent/query-builder layer over Postgres ltree — materialized-path storage with GiST-indexed ancestor/descendant operators. We get subtree filtering and breadcrumb-style queries without WITH RECURSIVE strings and without N+১ application-level traversal. Constraints to plan around: Postgres-only (hard lock-in), re-parenting rewrites descendant paths so write-heavy tree mutation needs a strategy, and the package is small (~35 stars, single maintainer) so we pin the version, keep usage behind our own repository/service boundary, and treat it as replaceable. Recommended first step: a one-sprint spike implementing one real subtree query and one move operation on production-shaped data, then decide.
How can I help you explore Laravel packages today?