Download the PHP package alex-kalanis/nested-tree without Composer
On this page you can find all versions of the php package alex-kalanis/nested-tree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alex-kalanis/nested-tree
More information about alex-kalanis/nested-tree
Files in alex-kalanis/nested-tree
Package nested-tree
Short Description PHP Library to process nested tree structures
License MIT
Homepage https://www.github.com/alex-kalanis/nested-tree
Informations about the package nested-tree
Nested Tree
Library to work with Nested tree set. Rework of Rundiz's library.
About
The PHP nested set model for create/read/update/delete the tree data structure (hierarchy).
It uses combination of nested and adjacency models. Also uses primary and foreign keys as simple integers, so you cannot use composed keys.
Requirements
- PHP version 8.1 or higher
Basic usage
Basic usage is about to set with corresponding columns in your app and then pass it into the libraries. Next you need to extend to describe your real table. For specific things like more columns you also need to set class. The most code is then set via DI. You can see that in tests.
DB structure
This library need following columns or their equivalents on affected table:
id
- PK on table, cannot be zero, because that is the same as top/root nodeparent_id
- FK to PK on the same table, can be null for top - depend on you DB schema, cannot be zero, because that is the same as top/root nodeleft
- left leaf of nested treeright
- right leaf of nested treelevel
- how deep is itposition
- where it is against others in the level group
Each column can be set to different name by change in TableSettings
class.
Running tests
The master
branch includes unit tests.
If you just want to check that everything is working as expected, executing the unit tests is enough.
phpunit
- runs unit and functional tests
Caveats
You must choose if you go with MariaDB or MySQL, because default implementation uses function ANY_VALUE() to go around the problem with non-standard implementation. So you may either use MySQL 5.7+ or disable directive in MariaDB. Or write custom query source which itself will go around this particular problem.
All versions of nested-tree with dependencies
ext-pdo Version *