Download the PHP package chekun/gremlin-php without Composer
On this page you can find all versions of the php package chekun/gremlin-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chekun/gremlin-php
More information about chekun/gremlin-php
Files in chekun/gremlin-php
Informations about the package gremlin-php
This is a Gremlin server client for PHP. Supported versions : M9-RC3
Changes
There are many changes but bellow are the most noticeable if you've used rexpro-php before
- Client now throw errors that you will need to catch
- Connection params have changes
- Messages class has been revamped and is independant from Connection (see documentation on how to use this)
- Unit testing will require some more configuration
- Runs sessionless by default (rexpro-php 2.3 & 2.4+ ran with sessions as the default)
- Gremlin code change g.V/E should now be written as g.V()/E()
Installation
PHP Gremlin-Server Client
For Gremlin-Server 3.0.0-M5+
Prefered method is through composer. Add the following to your composer.json file:
If you just want to pull and use the library do:
Namespace
The Connection class exists within the rexpro
namespace. (history: rexpro used to be the old protocol used by the driver in Tinkerpop2). This means that you have to do either of the two following:
Or
Examples
You can find more information by reading the API in the wiki.
Here are a few basic usages.
Example 1 :
Note that "graph" is the name of the graph configured in gremlin-server (not the reference to the traversal which is g = graph.traversal()
)
Example 1 bis (Writing the same with message object) :
Example 2 (with bindings) :
Example 3 (with session) :
Example 4 (transaction) :
Note that "graphT" above refers to a graph that supports transactions. And that transactions start a session automatically.
Example 5 (Using message object) :
Of course you can affect the current db message in the same manner through $db->message.
Adding Serializers
This library comes with a Json and an unused legacy Msgpack serializer. Any other serializer that implements SerializerInterface can be added dynamically with:
You can add many serializers in this fashion. When gremlin-server responds to your requests, gremlin-client-php will be capable of using the appropriate one to unserialize the message.
Unit testing
You will then need to run gremlin-server with the following configuration file : src/tests/gremlin-server-php.yaml
Just copy this file to <gremlin-server-root-dir>/conf/
And run the server using :
Note that you will not be able to test Transactions without a titan09-SNAPSHOT installation and custom configuration. Start an issue if you need more information.