lunarphp/nestedset
A Laravel package for working with nested set trees. Store and query hierarchical data such as categories, menus, and org structures efficiently, with support for creating, moving, and reordering nodes using left and right indexes. Ideal for fast ancestry and descendant lookups.
This is a hard fork of kalnoy/nestedset — the de facto nested-set implementation for Laravel — rebranded and re-namespaced under the Lunar organisation. The 1.0.0 release is a stabilisation release, not a feature release: namespace rebrand, native type declarations, static analysis, Testbench-based test suite, multi-engine CI, a global-scope hardening fix, and a zero-offset SQL fix.
Architecture fit. Nested sets remain a sound model for read-heavy hierarchies (category trees, menu structures, taxonomy) where depth-first traversal and subtree queries dominate and writes are comparatively rare. That trade-off has not changed. What has changed is ownership: this is now a Lunar-maintained fork, which means the technical evaluation is less about the algorithm and more about the supply-chain and divergence posture of the package.
Integration feasibility. Straightforward within the intended context. The package is a Laravel service provider plus a NodeTrait; adoption is a Composer require, a trait import, and a schema change adding _lft, _rgt, parent_id columns. For a greenfield Laravel 12 project — or anything inside the Lunar commerce stack — this is low-friction. For an existing kalnoy/nestedset consumer it is not drop-in: the namespace rebrand touches every use statement, trait import, config publish tag, and any subclassed node behaviour.
Technical risk. The material risks are:
Kalnoy\Nestedset\* must be migrated. A fork that changes the namespace cannot be swapped in behind an existing dependency without edits.kalnoy/nestedset going forward, and no stated upstream-sync policy in the notes.Key questions for the maintainers. What is the Composer package name and does it replace/provide the upstream package? Is this a permanent fork or a temporary vendored fork pending upstream Laravel 12 support? Is there a written upgrade guide enumerating the namespace and typing breaks, or is the changelog the only migration documentation? Is "Laravel 12/13" a forward-looking compatibility claim (i.e. illuminate/support: ^12|^13 with 13 unverified) or tested support? Does the multi-engine CI actually cover MySQL, Postgres, and SQLite for tree-mutating operations, or only the read paths? What is the security disclosure process?
Stack fit. Strong fit for Laravel 12+ applications and mandatory-by-default for Lunar commerce projects that depend on it transitively. Poor fit as a replacement for a working kalnoy/nestedset 6.x installation on Laravel 10/11 — the Laravel version floor and the namespace change both point the wrong way for a low-effort migration.
Migration path. Three distinct cases:
kalnoy/nestedset consumer on Laravel 12. Evaluate by replacing the Composer requirement, running a repo-wide namespace rewrite, then diffing behaviour. The real work is not the use statements — it is re-validating every query that touches a node model with a global scope, plus any subclass of the trait.Compatibility. Verify concretely rather than trusting the summary: confirm the illuminate/* constraint covers your actual Laravel version, confirm PHP version floor, and confirm the NodeTrait API surface against the upstream method list. If the API has silently dropped or renamed methods during modernisation, that is a hidden break the changelog does not call out.
Sequencing. Do not migrate alongside other framework work. Order: (1) pin and install in a branch, (2) namespace rewrite, (3) run existing test suite, (4) add explicit tests for subtree queries under each global scope your node models use, (5) run a tree-integrity check (_lft/_rgt contiguity and depth consistency) against a production-shaped dataset, (6) only then ship. Budget the global-scope revalidation as the largest line item, not the rename.
Maintenance. Low ongoing effort and low ongoing attention — but that attention must be deliberate. There is no runtime service to operate; the cost is dependency stewardship. Track the fork's releases, and on each one ask whether it has fallen behind upstream kalnoy/nestedset. A fork that drifts silently is a latent risk, not an acute one.
Support. This is the weakest dimension. A single-contributor fork with no stated support commitment means issue turnaround is best-effort. Escalation paths are the Lunar organisation's channels, not a vendor. Teams that need contractual support should not depend on it as a critical-path component without an internal fallback plan (fork it again, or vendor the trait).
Scaling. Nested sets are read-optimised and write-penalised, and nothing in this release changes that. Every insert, move, or delete rewrites _lft/_rgt across a portion of the table. At high write concurrency on deep or wide trees this serialises and will contend on locks. If the workload is write-heavy or the tree is large and mutating frequently, this is the wrong data model regardless of package quality — evaluate materialised paths or closure tables before adopting.
Failure modes. Ranked by likelihood: (1) tree corruption from writes performed outside a transaction or without wrapping in the package's node operations; (2) silent behavioural drift from the global-scope change, producing subtly wrong subtree results rather than errors; (3) subclass breakage from the native type declarations, surfacing as a fatal error on first use of an overridden method; (4) abandonment or drift from upstream, leaving a Laravel compatibility gap. Only (2) and (3) are introduced by this release; (1) and (4) are inherited properties of the dependency.
Ramp-up. Low for developers already familiar with nested sets, and low for anyone who has used kalnoy/nestedset — the API is intentionally similar. The ramp-up cost sits with reviewers and platform owners, who need to understand the fork relationship and the divergence policy before approving it, not with application developers writing queries.
How can I help you explore Laravel packages today?