2017 © Pedro Peláez
 

cakephp-plugin cakephp-neo4j

Neo4j Datasource for CakePHP

image

tlg05/cakephp-neo4j

Neo4j Datasource for CakePHP

  • Wednesday, December 20, 2017
  • by tlg05
  • Repository
  • 2 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Neo4j datasource for CakePHP 2.x

Requirements

  • PHP5
  • CakePHP >= 2.2.5

Installation

  • This datasource send neo4j request through restful API. So no php driver for Neo4j is required.
  • This project is a standard CakePHP plugin and it can be installed just like other plugins.

Place the repository under the Plugin folder, (*1)

cd my/app/Plugin 
git clone git://github.com/tlg05/cakephp-neo4j.git Neo4j

Load the plugin in bootstrap.php, (*2)

CakePlugin::load("Neo4j");

Provider database server information in database.php:, (*3)

class DATABASE_CONFIG {
    public $neo4j = array(
        'datasource' => 'Neo4j.Neo4jSource',
        'host' => 'localhost',
        'port' => 34618,
        'login' => 'neo4j',
        'password' => 'password'
    );

    public $test_neo4j = array(
        'datasource' => 'Neo4j.Neo4jSource',
        'host' => 'localhost',
        'port' => 33110,
        'login' => 'neo4j',
        'password' => 'password'
    );
}

Note, (*4)

  • Please make sure the model files use schemaless behavior.
  • There is model Node and Relationship to be extended. These 2 kinds of models are differentiated by the property $modelType

How it works

The test cases contain thorough examples of the usages. , (*5)

Nodes can be managed like normal CakePHP data:, (*6)

$data = array(
    'title' => 'test1',
    'body' => 'aaaa',
    'text' => 'bbbb'
);
$this->Post->create();
$this->Post->save($data);
$data = $this->Post->find('all');

Relationships are special. We need to provide start node, end node and the properties for a relationship. The properties of the relationship needs to be placed under properties tag instead of the root level of the data:, (*7)

$data = array(
    'start' => 'Post',
    'end' => 'Writer',
    'conditions' => array(
        'start.title' => 'The Old Man and the Sea',
        'end.name' => 'Hemingway'
    ),
    'properties' => array(
        'note' => ‘Hemingway writes The Old Man and the Sea'
    )
);
$this->Write->create();
$this->Write->save($data3, array("atomic" => false));

Data association is not supported yet. , (*8)

Author

Ligeng Te tlgnewlife@gmail.com, (*9)

The Versions

20/12 2017

dev-master

9999999-dev https://github.com/tlg05/cakephp-neo4j

Neo4j Datasource for CakePHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Ligeng Te

cakephp datasource neo4j