the-don-himself/gremlin-ogm 问题修复 & 功能扩展

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

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

the-don-himself/gremlin-ogm

Composer 安装命令:

composer require the-don-himself/gremlin-ogm

包简介

A PHP Object Graph Mapper for Tinkerpop 3+ compatible Graph Databases (JanusGraph, Neo4j, etc.) that allows you to persist data and run gremlin queries.

README 文档

README

A PHP Object Graph Mapper for Tinkerpop 3+ compatible Graph Databases (JanusGraph, Neo4j, etc.) that allows you to persist data and run gremlin queries.

Check out the TwitterGraph folder for an elaborate example of how to use gremlin-ogm to graph Twitter in a Graph Database.

Usage

Configure a Graph connection. This is simply a proxy to the underlying gremlin-server client for php aka brightzone/gremlin-php so you can check out the connection Class for configuration defaults and options Brightzone\GremlinDriver\Connection. For testing and development, I suggest something like the below

$options = [
    'host' => '127.0.0.1', 
    'port' => 8182, 
    'username' => null, 
    'password' => null, 
    'ssl' => [
      'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false
      ]
    ],
    'graph' => 'graph', 
    'timeout' => 10, 
    'emptySet' => true,
    'retryAttempts' => 3
];

After configuring options, initiate a Graph connection

use TheDonHimself\GremlinOGM\GraphConnection;

....

$graph = (new GraphConnection($options))->init();
$graph_connection = $graph->getConnection();

At this point you can open a connection to the Graph database and send gremlin-queries to it as shown.

// Open Connection
$graph_connection->open();

// Query Number of Vertices in Graph
$resultSet = $graph_connection->send('g.V().count()');

// Close Connection
$graph_connection->close();

Again these are just proxies to the underlying brightzone/gremlin-php library, so what does gremlin-ogm do? Gremlin-OGM helps you map PHP objects to Graph Vertexes, Edges, Properties and Indexes. It also provides a way to validate that mapping and point out areas where the schema fails. Moreover, the library attempts to create a cross-vendor abstraction layer because different providers might give different ways to execute gremlin commands.

Current Tested & Supported Vendors:

  • Amazon Neptune
  • Azure Cosmos DB
  • Datastax Enterprise Graph
  • JanusGraph on Compose
  • JanusGraph Self-Hosted
  • Neo4j
  • OrientDB

To tell the library of a specific vendor extend the options array as shown for self-hosted

$options = [
....
    'vendor' => [ 
      'name' => '_self', 
      'database' => 'janusgraph', 
      'version' => '0.3.1'
    ],
....
];

Omiting the version will make the library assume the latest.

An example configuration for JanusGraph on Compose would look like this.

$options = [
....
    'vendor' => [ 
      'name' => 'compose', 
      'graph' => 'twitter',
      'database' => 'janusgraph', 
      'version' => '0.3.1'
    ],
....
];

An example configuration for CosmosDB on Azure would look like this.

$options = [
....
    'vendor' => [ 
      'name' => 'azure', 
      'database' => 'cosmosdb'
    ],
....
];

Vendor information is critical to the library so as to know whether to enable certain features like bindings which is does by default and may not work in all situations. Submitted vendor information can now be gotten as an array under the graph object

$vendor = $graph->getVendor();

Sample Usage

Please Check Out The-Don-Himself/twitter-graph, for a full working sample code of how to use this library to map your Twitter connection and tweets onto a compatible graph database.

GraphQL

You might also be interested in The-Don-Himself/graphql2gremlin, an attempt to create a standard around transforming GraphQL queries to Gremlin Traversals.

the-don-himself/gremlin-ogm 适用场景与选型建议

the-don-himself/gremlin-ogm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.89k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2017 年 09 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「graph」 「neo4j」 「orientdb」 「janusgraph」 「gremlin-php」 「gremlin-ogm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 the-don-himself/gremlin-ogm 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-07