birdcar/laravel-label-graph 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

birdcar/laravel-label-graph

Composer 安装命令:

composer require birdcar/laravel-label-graph

包简介

A Laravel package for managing hierarchical labels as a DAG with materialized path routes

README 文档

README

CI Latest Version on Packagist Total Downloads License

Laravel package for hierarchical labels with multiple parents (DAG), lquery pattern matching (priority.*, *.bug), and materialized path routes for fast queries. Unlike traditional trees, labels can belong to multiple hierarchies—a "Wireless Gaming Mouse" can appear in both "Electronics > Mice" AND "Gaming > Accessories".

Perfect For

  • E-commerce categories: Products in multiple categories
  • Issue tracker labels: GitHub-style hierarchical labels with pattern queries
  • Content taxonomy: Nested topics with fast ancestor/descendant lookups
  • Permission hierarchies: Complex permission structures with multiple inheritance

Not For

Installation

composer require birdcar/laravel-label-graph

Publish and run migrations:

php artisan vendor:publish --tag=label-graph-migrations
php artisan migrate

Optionally publish the config:

php artisan vendor:publish --tag=label-graph-config

Quick Start

Create Labels

use Birdcar\LabelGraph\Models\Label;
use Birdcar\LabelGraph\Models\LabelRelationship;

// Create root labels
$priority = Label::create(['name' => 'Priority']);
$high = Label::create(['name' => 'High']);
$critical = Label::create(['name' => 'Critical']);

// Create hierarchy
LabelRelationship::create([
    'parent_label_id' => $priority->id,
    'child_label_id' => $high->id,
]);

LabelRelationship::create([
    'parent_label_id' => $high->id,
    'child_label_id' => $critical->id,
]);

// Routes are automatically generated:
// priority
// priority.high
// priority.high.critical

Attach Labels to Models

use Birdcar\LabelGraph\Models\Concerns\HasLabels;

class Ticket extends Model
{
    use HasLabels;
}

// Attach routes by path
$ticket->attachRoute('priority.high.critical');
$ticket->attachRoute('type.bug');

// Query by exact route
Ticket::whereHasRoute('priority.high')->get();

// Query by pattern (lquery-style: * matches zero or more labels)
Ticket::whereHasRouteMatching('priority.*')->get();  // priority and descendants
Ticket::whereHasRouteMatching('*.bug')->get();       // any path ending in bug

// Query descendants/ancestors
Ticket::whereHasRouteDescendantOf('priority')->get();
Ticket::whereHasRouteAncestorOf('priority.high.critical')->get();

Query Routes Directly

use Birdcar\LabelGraph\Models\LabelRoute;

// Find routes by pattern
LabelRoute::wherePathMatches('priority.*')->get();

// Find descendants of a path
LabelRoute::whereDescendantOf('priority')->get();

// Find ancestors of a path
LabelRoute::whereAncestorOf('priority.high.critical')->get();

Documentation

Full documentation available at birdcar.github.io/laravel-label-graph

Requirements

  • PHP 8.3+
  • Laravel 11.0+ or 12.0+
  • SQLite, MySQL 8.0+, or PostgreSQL 14+

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a PR.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Run tests: ./vendor/bin/pest
  4. Run linting: ./vendor/bin/pint && ./vendor/bin/phpstan analyse
  5. Commit your changes with a descriptive message
  6. Push to your branch and create a Pull Request

License

The MIT License (MIT). See LICENSE for details.

birdcar/laravel-label-graph 适用场景与选型建议

birdcar/laravel-label-graph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 birdcar/laravel-label-graph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 birdcar/laravel-label-graph 我们能提供哪些服务?
定制开发 / 二次开发

基于 birdcar/laravel-label-graph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-03