Weave 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 Nestedset Laravel Package

arcanedev/laravel-nestedset

Laravel Nested Set offers an efficient way to store and query hierarchical data using the nested set model, with a fluent API for creating, moving, and traversing trees and fast ancestor/descendant lookups without recursive queries.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package implements the Nested Set Model (_lft / _rgt / parent_id columns) as an Eloquent trait, replacing recursive parent-pointer queries with set-based reads: descendants, ancestors, subtree slices, and ordered trees resolve in a single indexed query instead of N round-trips. That is a genuinely strong fit for read-heavy, shallow-to-medium hierarchy workloads — category trees, org charts, menu/IA structures, permission trees, threaded comments read as trees. It is a poor fit for deep or write-heavy hierarchies (per-insert cost scales with the number of nodes to the right of the insertion point), for graphs (a node with multiple parents), or for teams already on PostgreSQL ltree or recursive CTEs, where the database can do this without a schema-level trade-off.

Note the package is effectively a redistribution of the well-established lazychaser/laravel-nestedset (now kalnoy/nestedset) under the ARCANEDEV namespace. That matters for evaluation: the model and API are proven, but this distribution is not the one receiving the fixes.

Integration feasibility. Mechanically trivial — composer require arcanedev/laravel-nestedset, add the trait, add three integer columns plus indexes via migration. The blocker is version compatibility, not effort. With a last release of 2017-02-01, the constraint set targets Laravel 5.x and PHP 5.6/7.0. Modern Laravel (9/10/11) and PHP 8.1+ will fail dependency resolution, and even if forced, the package predates PHP 8's stricter implicit-nullable and return-type semantics, Laravel's string-helper removal, and the HasAttributes/$casts changes. Expected real integration cost is not "install the package" but "fork, patch, and own the fork."

Technical risk. High, and concentrated in ownership rather than design:

Signal Value Interpretation
Stars 5 No community scrutiny; defects are not being surfaced by others
Dependents 0 No production reference base; you would be the first
Last release 2017-02-01 ~8 years without a tag; no PHP 8 / Laravel 8+ support
Score 0.055 Effectively disqualified on maintenance signals despite a high opportunity score (9.02)
License MIT Forking and vendoring are legally clean — the only real mitigation

The high opportunity score reflects the persistent demand for hierarchical data in Laravel, not the health of this artifact. Correcting for that, the risk profile is: abandoned dependency, single-maintainer-or-none, no security response path, and no upgrade path that does not involve your team writing the patches.

Key questions.

  • What is the actual tree depth and node count per tree, and the read/write ratio? (Nested set only pays off above roughly 3–4 levels or >1k nodes per tree; below that, parent_id plus a recursive CTE is simpler and has no write amplification.)
  • Is the hierarchy single-tree or multi-tenant scoped? Scoped trees (scopeAttributes) are supported but add a dimension to every write and to any corruption-repair tooling.
  • What is peak concurrent write rate to the tree? Nested set updates lock a range of rows; concurrent subtree moves are the primary corruption vector.
  • Do we need ordered siblings, or only structural membership? Ordering is where most nested-set operational incidents originate.
  • Can the team own a fork (patch, test, publish to a private registry, track upstream kalnoy/nestedset for fixes), or does the org require a supported dependency?
  • Is the target DB Postgres? If so, ltree or a closure table may dominate this design outright.

Recommendation: do not adopt this distribution. Adopt kalnoy/nestedset (same model and API, actively maintained, Laravel 11 / PHP 8.3 compatible), or use native recursive CTEs. Treat ARCANEDEV's package as a reference implementation only.

Integration Approach

Stack fit. Assume a standard Laravel + MySQL/Postgres + Redis stack. Nested set adds no infrastructure — no queue, no cache, no external service. That is its operational appeal: the hierarchy becomes an indexable property of the row, so WHERE _lft BETWEEN ? AND ? composes with existing scopes, pagination, and EXISTS subqueries. It fits cleanly if the ORM layer is Eloquent-centric; if the codebase does heavy raw SQL or repository abstractions, the trait's write-path magic (automatic _lft/_rgt maintenance on save/delete) will be invisible to reviewers and easy to bypass — a real defect source.

Migration path.

  1. Substitute the dependency first. Swap the Composer requirement to kalnoy/nestedset and confirm the API surface your code depends on (descendants(), ancestors(), toTree(), appendToNode(), saveAsRoot(), getNestedList()) is present. In practice the ARCANEDEV package is a namespace-shifted copy, so the substitution should be near-mechanical — validate this with a spike before committing to it.
  2. Backfill from the existing parent-pointer column. Add nullable _lft, _rgt, parent_id, depth; write a one-off idempotent command that walks the existing parent_id graph depth-first and assigns left/right values inside a transaction. Keep parent_id as the source of truth until the backfill is verified.
  3. Verify with a repair pass. Run a full-tree integrity check (_rgt - _lft parity, no overlapping intervals, contiguous values per scope) against a production snapshot before flipping reads.
  4. Cut reads over, then writes. Route descendant/ancestor reads to the nested-set columns first; only then enable the trait's write path. This isolates "wrong data" from "wrong maintenance."
  5. Rollback plan. Keep the parent_id column populated and authoritative-adjacent through at least one release so a bad tree can be rebuilt from pointers.

Compatibility. Verify against the actual runtime, not the README: PHP version, Laravel major, DB driver, and any soft-delete or multi-tenancy trait already on the models. Nested set and SoftDeletes interact badly if deletes are not scoped — a soft-deleted node still consumes its interval, and restoring a subtree into a shifted tree can corrupt it. Confirm $fillable/$guarded treatment of _lft/_rgt (they must not be mass-assignable) and that any model observers or saving hooks do not fire twice on moves.

Sequencing. Highest-leverage order: (1) dependency decision, (2) schema + indexes, (3) backfill + verification on a snapshot, (4) read cutover behind a feature flag, (5) write path enablement, (6) repair-tooling and runbook before the first production move operation. Do not compress steps 3 and 5.

Operational Impact

Maintenance. This is the dominant cost and the reason for the negative recommendation. You are not buying a dependency; you are buying a fork. Budget for: keeping a PHP 8/Laravel-compatible patch set, a private Composer registry entry or VCS path repository, a CI job that runs the package's own tree-integrity tests against your schema, and an owner on the team. If the org cannot name that owner, the decision is already made.

Support. No vendor, no active issue triage, no security response channel, and no dependents to watch for advisories. CVEs in an abandoned package are typically discovered by you or not at all. Mitigation: the surface area is small (one trait, no network or filesystem I/O, no unserialize), so the realistic exposure is a Laravel/PHP incompatibility — which manifests as hard failures, not silent ones. Vendor the code into the repo rather than pulling it at deploy time, so builds are deterministic.

Scaling. Reads scale well and are the reason to accept the model: a descendant query is one index range scan regardless of depth, versus N queries for the parent-pointer approach — a meaningful win for menu rendering, category pages, and permission resolution on hot paths. Writes do not scale: inserting or moving a node rewrites every row to its right, so a move near the root of a 100k-node tree touches ~100k rows in one transaction. Under concurrent writes this becomes lock contention and, at worst, deadlocks between sibling-tree operations. Practical guidance: cap tree size per scope, serialize structural writes through a queue where possible, keep depth modest, and never perform bulk reorders in a request cycle.

Failure modes.

  • Interval corruption — the classic. Any write that bypasses the trait (raw SQL, bulk insert, update on _lft/_rgt, truncate-and-seed scripts) leaves overlapping or gapped intervals, and the symptom is silently missing or duplicated descendants — not an exception. This is the highest-severity failure and it is invisible to standard tests.
  • Partial moves — a transaction that fails mid-move leaves a half-shifted tree unless the whole operation is wrapped; the trait does this, custom code doing bulk moves may not.
  • Soft-delete interaction — deleted nodes retaining intervals, restores landing in shifted ranges.
  • Concurrency — two simultaneous subtree moves racing on overlapping intervals.
  • Multi-tenant scope leakage — an unscoped query returning a tree from the wrong tenant; must be enforced at the query layer, not by convention.
  • Tooling gap — this package has no active repair CLI; you will write the nestedset:fix command, and you will need it at the worst possible time.

Ramp-up. The conceptual model (left/right interval encoding) is not intuitive to engineers who have only used parent_id, and the failure modes are silent, so ramp-up is longer than the modest API suggests. Expect roughly a day for a mid-level engineer to be productive on reads, and materially more for anyone writing structural operations or review responsibilities. Required artifacts: a short internal design note on the interval model and its write cost, a "do not touch _lft/_rgt" lint rule or code-review checklist, explicit tests for move/reorder/delete-subtree, and a runbook covering detection (integrity-check command) and recovery (rebuild from parent_id). Without those, the team's first encounter with corruption will be a production data incident rather than a test failure.

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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core