定制 efureev/laravel-trees 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

efureev/laravel-trees

最新稳定版本:v5.5.0

Composer 安装命令:

composer require efureev/laravel-trees

包简介

Multi-Tree structures for Laravel

README 文档

README

PHP Laravel Package PHP Version Laravel Version Total Downloads License composer.lock available Latest Stable Version Maintainability Test Coverage

A Laravel package for implementing multi-tree hierarchical structures using the Nested Set Model.

Overview

This package supports Multi-Tree structures (multiple root nodes) and allows movement of nodes between trees. It works with various model primary key types: int, uuid, and ulid.

Key Advantages

  • Multi-Tree Support: Manage multiple independent trees within the same table
  • Cross-Tree Operations: Move nodes between different trees with ease
  • Flexible Primary Keys: Works with various key types including int, uuid, and ulid
  • Comprehensive Tree Health Tools: Built-in validation and repair utilities for tree integrity
  • Performance Optimized: Efficiently retrieves hierarchical data with minimal database queries
  • Modern PHP Support: Utilizes modern PHP 8.x features and strict typing
  • Flexible Configuration: Highly customizable attribute naming and behavior
  • Well Documented: Complete documentation with practical examples
  • Thoroughly Tested: Comprehensive test suite ensuring reliability

What are nested sets?

Nested Set Model is an efficient way to store hierarchical data in relational databases:

The nested set model numbers nodes according to a tree traversal, which visits each node twice, assigning numbers in the order of visiting, and at both visits. This leaves two numbers for each node, which are stored as attributes. Querying becomes inexpensive: hierarchy membership can be tested by comparing these numbers. Updating requires renumbering and is therefore expensive.

Ideal Use Cases

NSM shows good performance when:

  • Trees are updated infrequently
  • Fast retrieval of related nodes is needed
  • Building multi-depth menus or category structures

Visualization

html tree console tree

Requirements

  • PHP: 8.2|8.3|8.4|8.5
  • Laravel: ^11., ^12.

It is highly recommended to use a database that supports transactions (like PostgreSQL) to protect tree structures from corruption.

Installation

composer require efureev/laravel-trees

Documentation

Testing

./vendor/bin/phpunit --testdox
# or
composer test

统计信息

  • 总下载量: 50.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 140
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 140
  • Watchers: 2
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-07