PHPackages                             bingher/tugraph - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. bingher/tugraph

ActiveLibrary

bingher/tugraph
===============

TuGraph PHP Driver with Restfull API

v0.0.9(1y ago)041MITPHP

Since Mar 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hbh112233abc/tugraph)[ Packagist](https://packagist.org/packages/bingher/tugraph)[ RSS](/packages/bingher-tugraph/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (10)Used By (0)

PHP driver for TuGraph
======================

[](#php-driver-for-tugraph)

Install
-------

[](#install)

```
composer require bingher/tugraph
```

Use
---

[](#use)

- use origin cypher query

```
use bingher\tugraph\TuGraph;

$config = [
    'uri' => '',
    'user' => '',
    'password' => '',
    'graph' => '',
];

$tu = new TuGraph($config);

$sql = 'Match p = (n)-[]-(m) Return p';
$result = $tu->graph('')->call($sql);
```

- use php-cypher-dsl query

```
use bingher\tugraph\TuGraph;
use function WikibaseSolutions\CypherDSL\node;
use function WikibaseSolutions\CypherDSL\query;

$config = [
    'uri' => '',
    'user' => '',
    'password' => '',
    'graph' => '',
];

$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('')->call($statement);
```

- example

```
use bingher\tugraph\TuGraph;

$config = [
    'uri' => '',
    'user' => '',
    'password' => '',
    'graph' => '',
];

$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 = '';
$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
---

[](#ref)

[TuGraph Restfull API](https://tugraph-db.readthedocs.io/zh-cn/latest/7.client-tools/7.restful-api.html)[TuGraph Cypher API](https://tugraph-db.readthedocs.io/zh-cn/latest/8.query/1.cypher.html)[php-cypher-dsl wiki](https://github.com/neo4j-php/php-cypher-dsl/wiki)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance46

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

9

Last Release

405d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c1da3d6c4d29c7a57ccd6d492fadb30cdb3467a8f1517ca07babf87f73de54f?d=identicon)[hbh112233abc](/maintainers/hbh112233abc)

---

Top Contributors

[![hbh112233abc](https://avatars.githubusercontent.com/u/7788164?v=4)](https://github.com/hbh112233abc "hbh112233abc (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bingher-tugraph/health.svg)

```
[![Health](https://phpackages.com/badges/bingher-tugraph/health.svg)](https://phpackages.com/packages/bingher-tugraph)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
