All Projects → mcuadros → php-cayley

mcuadros / php-cayley

Licence: MIT license
PHP wrapper of the Google's Cayley graph database REST interface

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

php-cayley Build Status

PHP Wrapper for the Google's Cayley graph database REST interface.

Cayley is an open-source graph inspired by the graph database behind Freebase and Google's Knowledge Graph. Its goal is to be a part of the developer's toolbox where Linked Data and graph-shaped data (semantic webs, social networks, etc) in general are concerned.

The Cayley's default query language is called Gremlin based on JavaScript. php-cayley is a replica of this Gremlin Javascript API in PHP, all the methods and patterns from Gremlin are applicable to this library.

Requirements

  • php >=5.5.0
  • guzzlehttp/guzzle ~6.0

Installation

The recommended way to install php-cayley is through composer. You can see the package information on Packagist.

{
    "require": {
        "mcuadros/php-cayley": "dev-master"
    }
}

Usage

Basic example

$cayley = new Cayley\Client();
$query = $cayley->graph()->vertex('Humphrey Bogart')->all();
$result = $cayley->query($query);
print_r($result);

Morphism example

$cayley = new Cayley\Client();

$filmToActor = $cayley->graph()
    ->morphism()
    ->out('/film/film/starring')
    ->out('/film/performance/actor');

$query = $cayley->graph()
    ->vertex()
    ->has('name', 'Casablanca')
    ->follow($filmToActor)
    ->out('name')
    ->all();

$starring = $cayley->query($query);
foreach($starring as $actor) {
    var_dump($actor['id']);
}

These examples are based on the data contained in the example database 30kmoviedata.nq.gz

For more information please read Gremlin Javascript API documentation.

Tests

Tests are in the tests folder. To run them, you need PHPUnit. Example:

$ phpunit --configuration phpunit.xml.dist

License

MIT, see LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].