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

Tree Laravel Package

bluem/tree

bluem/tree is a PHP library for building and manipulating hierarchical tree structures from flat, parent-child data. It offers node traversal, filtering, and rendering helpers, making it useful for categories, menus, and other nested data in Laravel or plain PHP projects.

Deep Wiki
Context7

PHP library for handling tree structures based on parent IDs, e.g. a self-joined database table

Frequently asked questions about Tree
How do I install bluem/tree in a Laravel app?
Install it with Composer using composer require bluem/tree. It is a framework-agnostic PHP library rather than a native Laravel package, so you will not get a service provider or facade. Wrap it behind an application-owned repository or service before using it in controllers, jobs, or Blade views.
Does bluem/tree integrate with Laravel Eloquent models?
Not natively. The library works with parent_id adjacency-list data, so you typically load rows through Eloquent or the query builder and map them into the library's node structure. Keep that mapping inside an adapter so your models and views do not depend directly on the third-party API.
What database schema does bluem/tree need for a tree?
It expects a self-referencing parent_id column, like a categories table where each row points to its parent. Add indexes on parent_id, plus any root or tenant identifier and sort column you use. Confirm foreign-key and delete behavior for your MySQL, PostgreSQL, or SQLite setup.
Can bluem/tree handle multiple roots or multi-tenant trees?
Multiple roots and scoped trees are common adjacency-list requirements, but you must verify the library's exact support during a spike. If it assumes one global tree, filter by tenant or root ID in your adapter and build separate node sets per scope. Test ordering and depth calculations inside each scope.
How does bluem/tree handle moving nodes and preventing cycles?
Tree moves are data-integrity sensitive, so do not rely on the library alone. Put move operations behind guarded service methods, run them in a transaction, and add explicit cycle detection that rejects making a node a descendant of itself. Also test concurrent moves and partial deletes.
Is bluem/tree compatible with Laravel 11 and PHP 8.3?
Check the package's Composer constraints before scheduling work, because this is a generic PHP library and Laravel version support is not guaranteed. Test against the exact PHP, Laravel, and database versions you run in production. If constraints conflict, isolate it behind an adapter or evaluate a maintained alternative.
Why is bluem/tree slow for deep trees and large category lists?
Adjacency-list traversal can produce recursive queries or N+1 access patterns at depth. Limit how much of the tree you load, index parent_id and sort columns, and cache rendered menus or breadcrumbs where possible. Load-test with realistic depth and row counts before rolling out.
Is bluem/tree actively maintained and safe to use in production?
The repository is unknown and the package has limited popularity, so maintenance and security response are uncertain. Pin the version, monitor advisories, keep adapter tests in your own repo, and plan to vendor or fork it if it becomes stale. Assign an internal owner for upgrades and incident response.
What are alternatives to bluem/tree for nested categories in Laravel?
Alternatives include kalnoy/nestedset for nested-set models, closure-table packages, materialized-path implementations, and recursive common table expressions in PostgreSQL or MySQL 8. The right choice depends on read/write ratio, move frequency, and whether your schema already uses nested sets. Compare maintenance and Laravel integration before switching.
How should I test bluem/tree traversal, filtering, and rendering?
Write integration tests around your adapter using representative trees, including multiple roots, deep branches, and empty results. Assert traversal order, depth, filtering, and rendered output, and add failure tests for cycles, orphaned parents, and deletes. Run them against the same database engine you use in production.
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.
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
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console