oliva / tree
Utility for handling tree data structures and building trees from flat data stored in database tables and alike.
Installs: 23 425
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: ^8.0 || ^7.4
Requires (Dev)
- nette/tester: ^2
- tracy/tracy: ^2.3
README
๐ข
It's been a long time since the dawn of this library. It still runs on modern PHP, but it's far from optimal.
See a modern reimplementation of this library here: ๐
dakujem/oliva
Oliva Tree
Utility for handling tree data structures.
๐ฟ
composer require oliva/tree
๐ documentation
Oliva Tree is a powerful yet simple to use utility for handling tree data structures in PHP.
Useful for handling tree data stored in database or for performing search and filter operations on arbitrary tree structures.
Why use Oliva Tree?
- data manipulation
- write components like menus, tree views, grids, data lists, etc. with ease.
- it's documented
- battle and unit tested
What can you do with Oliva Tree?
- build tree structures from arbitrary flat data with support for
- materialized path data model
- recursive trees (parent - id) (adjacency list data model, self-joined tables)
- build trees from JSON strings
- build trees using a fluent interface
- seamlessly wrap objects with
Node
class and keep using them as before - enhance functionality of data already in tree structures
- find nodes, breadth-first or depth-first
- filter nodes by any condition
- compare trees, nodes, sub-trees
- provide means for easy tree structure manipulation
- transform tree structures (back) to flat data, in breadth-first or depth-first manner
Documentation
For more in-depth information, use cases and other examples, see the documentation section.
Installation
composer require oliva/tree
Older versions of Oliva Tree run on PHP 5.4 and up and also PHP 7.0 and up.
Versions since 1.3
support PHP 7.4+ and PHP 8+ (including PHP 8.2 and PHP 8.3).
Changelog
Notable changes only.
1.4
- PHP 8.1+ supported
- some return type-hints added
1.3
- PHP 8.0 support added
- PHP >= 7.4 required
- updated to a simple permissive license (Unlicense)
1.2.3
- updated licensing to enable multi-licensing, i.e. one can now use any of GPL, MIT or BSD license, see license.md for more information
Missing features
I never added these...
- prunning (condition- and depth-based)
- node moving mechanism / helpers
- tree writers - alter the node's data to reflect current tree structure (prepare for storage) - a counterpart to tree builders
- unite and document exception codes
- support for nested sets data model
On the second thought, most of these things are outside the scope of this library anyway.
Notes
Great thank's to folks in Via Aurea for providing valuable support, motivation and real-world testing.
๐
I finally found a reason to reimplement the idea of this tool for building and managing trees.
See the modern reimplementation here: ๐
dakujem/oliva