Download the PHP package brightzone/gremlin-php without Composer

On this page you can find all versions of the php package brightzone/gremlin-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gremlin-php

This is a Gremlin server client for PHP. It allows you to run gremlin queries against graph databases (including Neo4j, Titan, etc.). You can find a beginner tutorial by reading the Get up and running with Tinkerpop 3 and PHP article.

This driver currently supports TP3+.

For a TP2 compatible php driver please check rexpro-php

Build Status Latest Stable Version Coverage Status Total Downloads License

Join the chat at https://gitter.im/PommeVerte/gremlin-php

Installation

PHP Gremlin-Server Client

Preferred method is through composer.

Either run :

Or add:

to the require section of your composer.json file

Tinkerpop 3.3.x server Configuration

This driver now supports GraphSON 3.0 with a basic beta serializer. You can use this serializer by doing :

If you wish to continue using the stable GraphSON 1.0 serializer it is necessary to configure the server to use GraphSON 1.0. To do this, make sure to replace the # application/json serializer in your gremlin-server.yaml configuration file with the following:

Upgrading

BC breaking changes are introduced between major version changes. So if you're upgrading to 2.0.0 from 1.0. Please read the CHANGELOG

Usage

The Connection class exists within the GremlinDriver namespace.

Features

You can find more information by reading the API.

Basic connection

A basic connection can be created by creating a new Connection as follows.

Note that "graph" is the name of the graph configured in gremlin-server (not the reference to the traversal which is g = graph.traversal())

It is also possible to specify authentication credentials as follows:

Check the SSL section for an example using the configuration files provided by TP.

You can find all the options available to the Connection class here.

Bindings

Bindings are important for several reasons. They protect from code injections, but they also prevent the server from having to compile scripts on every run.

The following example illustrates both of these points:

As you can see from the example above, not using bindings can be costly as the server needs to compile every new script.

Sessions

Sessions allow you to maintain variables and bindings accross multiple requests.

Transactions

Transactions will allow you to revert or confirm a set of changes made accross multiple requests.

Note that "graphT" above refers to a graph that supports transactions. And that transactions start a session automatically. You can check which features are supported by your graph with graph.features().

It is also possible to express transactions with a lambda notation:

This will commit these changes or return an Exception if an error occured (and automatically rollback changes). The advantage of using this syntax is that it allows you to handle fail-retry scenarios.

It is sometimes important to implement a fail-retry strategy for your transactional queries. One such example is in the event of concurrent writes to the same elements, the databases (such as titan) will throw an error when elements are locked. When this happens you will most likely want the driver to retry the query a few times until the element is unlocked and the write can proceed. For such instances you can do:

This will attempt to run the query 10 times before fully failing. It is worth noting that retryAttempts also works with -out of session- queries:

Advanced features

Message objects

Sometimes you may need to have greater control over individual requests. The reasons for this can range from using custom serializers, different query languages (gremlin-python, gremlin-scala, java), to specifying a request timeout limit or a local alias. For these cases you can construct a custom Message object as follows:

Of course you can affect the current db message in the same manner through $db->message.

For a full list of arguments and values available please refer to the TinkerPop documentation for drivers.

SSL

When security is important you will want to use the SSL features available. you can do so as follows:

Note that with php 5.6+ you will need to provide certificate information in the same manner you would to a stream_context_create(). In which case your Connection() call could look something like the following (replace with your own certificates and/or bundles):

If you're using the bundled gremlin-server-secure.yaml file, you can use this configuration to connect to it. For dev and testing purposes you can use this configuration

Serializers

Serializers can be changed on the gremlin-server level. This allows users to set their own serializing rules. This library comes by default with a Json 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-php will be capable of using the appropriate one to unserialize the message.

API

You can find the full api here.

Unit testing

Neo4J is required for the full test suit. It is not bundled with gremlin-server by default so you will need to manually install it with:

(replace the version number by the one that corresponds to your gremlin-server version)

Copy the following files :

You will then need to run gremlin-server in the following manner :

Then run the unit test via:

Browser /tests/webtest.php file

If your gremlin-php folder is on the web path. You can also load tests/webtest.php instead of using the command line to run PHPUNIT tests.

This is useful in some wamp or limited access command line situations.


All versions of gremlin-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brightzone/gremlin-php contains the following files

Loading the files please wait ....