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 Trees

Laravel Trees Laravel Package

efureev/laravel-trees

Laravel Trees adds nested-set tree support to Eloquent models, making it easy to build, query, move, and reorder hierarchical data like categories or menus with efficient ancestor/descendant operations and a simple API.

View on GitHub
Deep Wiki
Context7

tree structures with best perfomance

Frequently asked questions about Laravel Trees
What is efureev/laravel-trees used for in Laravel?
Laravel Trees adds nested-set tree support to Eloquent models for hierarchical data such as categories, menus, and org units. It is built for efficient ancestor, descendant, and subtree queries plus a simple API for building, moving, and reordering trees. It is not a general graph library, so it fits read-heavy hierarchical data better than arbitrary graph relationships.
Which PHP and Laravel versions does laravel-trees v7 require?
Version 7 requires PHP ^8.5 and Laravel 13, so it cannot be installed on PHP 8.4 or below and is effectively greenfield-only until those platforms are upgraded. Teams on older stacks should pin v6 and treat the PHP and Laravel upgrade as the gating dependency. The provided evaluation does not specify the v6 support policy or whether Laravel 12 support will be widened.
How do I install efureev/laravel-trees with Composer?
Install it with Composer using composer require efureev/laravel-trees, then follow the package documentation for model traits, schema setup, and configuration. Confirm your application meets the v7 floor of PHP 8.5 and Laravel 13 before installing, or pin an earlier compatible release. Integration testing against real tree data is recommended because v7 fixes mutation behavior.
How does laravel-trees store hierarchical data?
Laravel Trees uses a nested-set model rather than a simple parent link. Each node's position is represented by tree bounds, which makes ancestor and descendant reads efficient. The package documentation's Concepts.md explains when a nested set is the right shape versus a simpler parent link.
Is laravel-trees suitable for write-heavy trees?
Nested-set writes shift bounds and can affect many rows, so write-heavy trees or deep, frequently mutated hierarchies remain the architectural constraint in v7. The release does not change that write amplification. For those cases, evaluate a simpler parent-link model or another approach before adopting Laravel Trees.
What breaking changes are in laravel-trees v7?
The v7 floor is PHP ^8.5 and Laravel 13. The breaking surface includes three internal-only signatures, HealthyChecker::check returning six entries instead of three, Table::fromQuery becoming static and dropping pre-call instance configuration, and the exception import changing to Fureev\Trees\Exceptions\InvalidConfigException. Behavior fixes also change tree mutations such as delete re-parenting and bound shifts, so integration testing is mandatory.
How do I check the health of a tree with laravel-trees?
Use HealthyChecker to run integrity checks; in v7 check() returns six entries and RangeCheck, RootCheck, and MissingParentCheck run by default. DuplicatesCheck and WrongParentCheck now return node counts rather than pair or triple counts, with zero still meaning healthy and isBroken unaffected. CI gates or dashboards that compare the array literally or assert a clean result may start firing after upgrade.
Will upgrading to laravel-trees v7 fix corrupted tree data?
No. Upgrading the code does not repair data that was already made inconsistent by v6 delete re-parenting or bound-shift defects. Budget an audit-and-repair pass against real trees, and check with the maintainer whether a repair or rebalance path is provided or left to consumers.
How should I test a Laravel app after upgrading to laravel-trees v7?
Add integration tests against real tree data covering moves, deletes, re-parenting, reordering, eager-loaded ancestors and descendants, and health-check output. The v7 fixes change mutation behavior and ordering, and HealthyChecker now returns six entries, so assertions built on v6 results are not reliable. Treat testing as mandatory rather than optional.
What are alternatives to laravel-trees for hierarchical data in Laravel?
For simple or write-heavy hierarchies, a plain parent_id adjacency model may be a better fit than a nested set. General graph needs are outside this package's scope, and other nested-set packages are the closest alternatives for Eloquent. Laravel Trees is strongest for read-heavy subtree queries such as categories, org units, and menus.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager