承接 bingher/tugraph 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bingher/tugraph

Composer 安装命令:

composer require bingher/tugraph

包简介

TuGraph PHP Driver with Restfull API

README 文档

README

Install

composer require bingher/tugraph

Use

  • use origin cypher query
use bingher\tugraph\TuGraph;

$config = [
    'uri' => '<API Base Uri>',
    'user' => '<User>',
    'password' => '<Password>',
    'graph' => '<Graph name,default:empty>',
];

$tu = new TuGraph($config);

$sql = 'Match p = (n)-[]-(m) Return p';
$result = $tu->graph('<GraphName>')->call($sql);
  • use php-cypher-dsl query
use bingher\tugraph\TuGraph;
use function WikibaseSolutions\CypherDSL\node;
use function WikibaseSolutions\CypherDSL\query;

$config = [
    'uri' => '<API Base Uri>',
    'user' => '<User>',
    'password' => '<Password>',
    'graph' => '<Graph name,default:empty>',
];

$tu = new TuGraph($config);

$tom = node("Person")->withProperties(["name" => "Tom Hanks"]);
$coActors = node();

$statement = query()
    ->match($tom->relationshipTo(node(), "ACTED_IN")->relationshipFrom($coActors, "ACTED_IN"))
    ->returning($coActors->property("name"))
    ->build();

$result = $tu->graph('<GraphName>')->call($statement);
  • example
use bingher\tugraph\TuGraph;

$config = [
    'uri' => '<API Base Uri>',
    'user' => '<User>',
    'password' => '<Password>',
    'graph' => '<Graph name,default:empty>',
];

$tu = new TuGraph($config);

$zg = TuGraph::node('主公');
$r  = TuGraph::link(['隶属']);
$wj = TuGraph::node();

$res = $tu->graph('三国')
    ->match($zg->relationship($r, $wj))
    ->where([$zg->property('name')->equals('曹操'), $wj->property('name')->startsWith('夏侯')])
    ->returning([$zg, $r, $wj])
    ->call();

$sql = $tu->sql();
var_dump($sql);
$this->assertStringMatchesFormat("MATCH (%s:主公)-[%s:隶属]-(%s) WHERE ((%s.name = '曹操') AND (%s.name STARTS WITH '夏侯')) RETURN %s, %s, %s", $sql);
var_dump($res);

query result

array(4) {
  ["elapsed"]=>float(0.0040798187255859375)
  ["header"]=>
  array(3) {
    [0]=>
    array(2) {
      ["name"]=>string(35) "varc9815f2faa847fca20a93a8d940604e5"
      ["type"]=>int(1)
    }
    [1]=>
    array(2) {
      ["name"]=>string(35) "var741b1da0dd39e501fc9adf7febe0706a"
      ["type"]=>int(2)
    }
    [2]=>
    array(2) {
      ["name"]=>string(35) "vard064169534b1fb4d74dbec62d435ef5a"
      ["type"]=>int(1)
    }
  }
  ["result"]=>
  array(3) {
    [0]=>
    array(3) {
      [0]=>string(170) "{"identity":91,"label":"主公","properties":{"camp":"魏","family":"谯县曹氏","father_position":"太尉","hometown":"豫州","name":"曹操","position":"魏武帝"}}"
      [1]=>string(94) "{"dst":91,"forward":false,"identity":0,"label":"隶属","label_id":2,"src":28,"temporal_id":0}"
      [2]=>string(126) "{"identity":28,"label":"武将","properties":{"camp":"魏","family":"谯县夏侯氏","hometown":"豫州","name":"夏侯惇"}}"
    }
    [1]=>
    array(3) {
      [0]=>string(170) "{"identity":91,"label":"主公","properties":{"camp":"魏","family":"谯县曹氏","father_position":"太尉","hometown":"豫州","name":"曹操","position":"魏武帝"}}"
      [1]=>string(94) "{"dst":91,"forward":false,"identity":0,"label":"隶属","label_id":2,"src":34,"temporal_id":0}"
      [2]=>string(126) "{"identity":34,"label":"武将","properties":{"camp":"魏","family":"谯县夏侯氏","hometown":"豫州","name":"夏侯尚"}}"
    }
    [2]=>
    array(3) {
      [0]=>string(170) "{"identity":91,"label":"主公","properties":{"camp":"魏","family":"谯县曹氏","father_position":"太尉","hometown":"豫州","name":"曹操","position":"魏武帝"}}"
      [1]=>string(94) "{"dst":91,"forward":false,"identity":0,"label":"隶属","label_id":2,"src":35,"temporal_id":0}"
      [2]=>string(126) "{"identity":35,"label":"武将","properties":{"camp":"魏","family":"谯县夏侯氏","hometown":"豫州","name":"夏侯渊"}}"
    }
  }
  ["size"]=>int(3)
}
  • use result function
$sql = '<cypher query>';
$callResult = $tu->call($sql);
$result = $tu->result($callResult);
var_dump($result);

result

array (
    'nodes' => array(...node array),
    'edges' => array(...edge array),
    'table' => array(...array),
)

Ref

TuGraph Restfull API TuGraph Cypher API php-cypher-dsl wiki

bingher/tugraph 适用场景与选型建议

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

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

围绕 bingher/tugraph 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-13