kcesys/php-genealogy
Composer 安装命令:
composer require kcesys/php-genealogy
包简介
Framework-agnostic PHP library for genealogy graph structures
README 文档
README
A framework-agnostic PHP SDK for managing genealogy data structures compatible with @kcesys/react-genealogy.
Installation
composer require kcesys/php-genealogy
Usage
Use the Builder to transform your raw data (Arrays, Objects, Database Models) into a valid Graph structure.
use KCESYS\Genealogy\Builder; $users = [ (object)['id' => 1, 'name' => 'Grandpa', 'father_id' => null], (object)['id' => 2, 'name' => 'Father', 'father_id' => 1], ]; $graph = Builder::from($users) ->mapId(fn($u) => $u->id) ->mapLabel(fn($u) => $u->name) ->mapParents(fn($u) => $u->father_id ? [$u->father_id] : []) ->build(); // Output JSON for React echo json_encode($graph);
Manual Construction
You can also build the graph manually using FamilyNode.
use KCESYS\Genealogy\GenealogyGraph; use KCESYS\Genealogy\FamilyNode; $graph = new GenealogyGraph(); $node = new FamilyNode('1', ['label' => 'Me']); $graph->addNode($node);
统计信息
- 总下载量: 133
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-15