OrientDB PHP Library

一组PHP库,以便从PHP中使用OrientDB。(A set of PHP libraries in order to use OrientDB from PHP.)

  • 所有者: doctrine/orientdb-odm
  • 平台: BSD, Linux, Mac, Windows
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

OrientDB PHP Library

什么是Orient?

一组用于从PHP中使用和管理任何OrientDB实例的工具。

Orient包括:

  • HTTP协议绑定
  • 查询构建器
  • 数据映射器(Object Graph Mapper)

如果您不知道 OrientDB ,请查看其文档

克隆后

为了能够运行Orient提供的示例和测试套件,您必须首先输入克隆存储库的根,并使用Composer初始化所有需要的依赖项。 我们在 bin/ 子目录中提供了一个实用程序脚本来简化此过程,因此您可以执行以下操作:

$ ./bin/initialize-dependencies.sh

绑定的当前状态

绑定完成:它是一个HTTP客户端包装器,其中一些方法绑定到OrientDB的HTTP接口。

它的用法很简单:

$parameters = Doctrine\OrientDB\Binding\BindingParameters::create('http://admin:admin@127.0.0.1:2480/demo');
$orient = new Doctrine\OrientDB\Binding\HttpBinding($parameters);
$output = $orient->query("SELECT FROM Address");

foreach ($output->getResult() as $address) {
    var_dump($address->street);
}

使用PHP5.3标准自动加载器( https://gist.github.com/221634 )。

查询构建器的当前状态

查询构建器已完成,未来我们将考虑OrientDB的集成 Graph Edition: http://code.google.com/p/orient/wiki/GraphEdTutorial

要利用QB,你只需要实例化一个Query对象:

 use Doctrine\OrientDB\Query\Query;

$query = new Query();
$query->from(array('users'))->where('username = ?', "admin");

echo $query->getRaw();      // SELECT FROM users WHERE username = "admin"

Query对象包含许多子命令,如SELECT,DROP,GRANT,INSERT 等等......

您也可以使用这些命令:

 use Doctrine\OrientDB\Query\Command\Select;

$select = new Select(array('users'));
echo $select->getRaw();     // SELECT FROM users

然而,我们强烈反对这种做法:命令会改变,查询被视为门面, - 希望 - 不是。

你最好看一下Query类的测试以及它的子命令来获取 全面了解可用的命令:以便与OrientDB的本机相匹配 类似SQL的合成器我们试图保留这些名称和东西,但有一些东西 已经改变了。

映射器的当前状态

我们开始研究mapper,现在它能够将OrientDB响应(在StdObject中转换)映射到注释映射的POPO。 还有收藏品可以正常保湿。

然而,它的工作量很大,所以不要指望能够在几周内使用它。接下来的步骤是:

  • 水合OrientDB本地数据类型(包括浮点数,嵌入集|链接列表,嵌入式地图|链接列表和其他许多...)
  • 提供基础知识库类
  • 从ODM到OrientDB的持久性实现

实用程序

Orient还为PHP开发人员提供了一些实用程序:它们是Dijkstra算法的实现。

 use Doctrine\OrientDB\Graph\Graph;
use Doctrine\OrientDB\Graph\Vertex;
use Doctrine\OrientDB\Graph\Algorithm\Dijkstra;

$graph = new Graph();

$rome = new Vertex('Rome');
$paris = new Vertex('Paris');
$london = new Vertex('London');

$rome->connect($paris, 2);
$rome->connect($london, 3);
$paris->connect($london, 1);

$graph->add($rome);
$graph->add($paris);
$graph->add($london);

$algorithm = new Dijkstra($graph);
$algorithm->setStartingVertex($rome);
$algorithm->setEndingVertex($london);

var_dump($algorithm->solve());

测试

测试套件可以通过从存储库的根目录执行 phpunit 来启动。

默认情况下,该套件不会执行集成测试,以验证我们的实现对正在运行的OrientDB实例的正确行为。 由于集成测试使用 @组 注释,可以通过在 phpunit.xml 中默认启用它们,方法是向排除组列表中的 integration 组添加注释, 如果您只是想在一次执行的基础上执行它们,请首先使用此脚本加载装置

php ./test/Integration/fixtures/load.php

然后使用附加的 --group 参数启动套件:

phpunit --group __nogroup__,integration

也可以使用 PHP_CodeBrowser 生成一个显示库的代码健康状况的HTML报告,并与以下依赖关系配对 (除了 phpunit ):

  • phpcpd
  • phpdcd
  • phploc
  • phpmd
  • phpdepend
  • phpcb

从存储库的根目录执行 ./bin/report.sh 将在 log/report/index.html 中生成报告。

要求

这些是使用库的要求:

  • PHP >= 5.3.3
  • OrientDB >= 1.2.0

为了启动测试套件PHPUnit 3.6是必需的。

跟踪器和软件生命周期

请参阅: https://github.com/doctrine/orientdb-odm/issues

更多文件

如果你想看一看PHPDoc文档,你可以使用doxygen:

sudo apt-get install doxygen

然后使用docs目录下提供的脚本:

doxygen docs/orient.d

它将在文件夹docs/html下生成技术文档。

主要指标

概览
名称与所有者doctrine/orientdb-odm
主编程语言PHP
编程语言PHP (语言数: 2)
平台BSD, Linux, Mac, Windows
许可证MIT License
所有者活动
创建于2011-02-13 20:12:32
推送于2021-10-27 21:58:44
最后一次提交2021-10-28 00:58:44
发布数8
最新版本名称1.0.0-beta7 (发布于 )
第一版名称beta-1 (发布于 )
用户参与
星数155
关注者数29
派生数54
提交数547
已启用问题?
问题数158
打开的问题数41
拉请求数34
打开的拉请求数5
关闭的拉请求数5
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

OrientDB PHP Library

Build Status
Total Downloads
Latest Stable Version

What's Orient?

A set of tools to use and manage any OrientDB instance from PHP.

Orient includes:

  • the HTTP protocol binding
  • the query builder
  • the data mapper ( Object Graph Mapper )

If you don't know OrientDB take a look at its Documentation.

After cloning

In order to be able to run the examples and the test suite provided by Orient, you must first enter the root of
the cloned repository and initialize all the needed dependencies using Composer.
We provide an utility script in the bin/ subdirectory to ease this process so you can just do the following:

$ ./bin/initialize-dependencies.sh

Current status of the binding

The binding is complete: it is an HTTP client wrapper with some methods bound to OrientDB's HTTP interface.

Its usage is straightforward:

$parameters = Doctrine\OrientDB\Binding\BindingParameters::create('http://admin:admin@127.0.0.1:2480/demo');
$orient = new Doctrine\OrientDB\Binding\HttpBinding($parameters);
$output = $orient->query("SELECT FROM Address");

foreach ($output->getResult() as $address) {
    var_dump($address->street);
}

Use the PHP5.3 standard autoloader (https://gist.github.com/221634).

Current status of the query builder

The query-builder is finished, in the future we will consider the integration of OrientDB
Graph Edition: http://code.google.com/p/orient/wiki/GraphEdTutorial.

To take advantage of the QB you only have to instantiate a Query object:

use Doctrine\OrientDB\Query\Query;

$query = new Query();
$query->from(array('users'))->where('username = ?', "admin");

echo $query->getRaw();      // SELECT FROM users WHERE username = "admin"

The Query object incapsulates lots of sub-commands, like SELECT, DROP, GRANT, INSERT
and so on...

You can use also those commands:

use Doctrine\OrientDB\Query\Command\Select;

$select = new Select(array('users'));
echo $select->getRaw();     // SELECT FROM users

However, we strongly discourage this approach: commands will change, Query, thought as a facade, - hopefully - not.

You'd better take a look at the tests of the Query class and its subcommands to get
a full overview of the available commands: in order to match OrientDB's native
SQL-like synthax we tried to preserve names and stuff like that, but a few things
have changed so far.

Current status of the mapper

We started working on the mapper and, right now, it is able to map OrientDB responses (converted in StdObject) to annotation-mapped POPOs.
Also collections are hydrated properly.

However, it's under heavy work, so don't expect to be able to use it in a few weeks. Next steps are:

  • hydrate OrientDB native data-type (it includes floats, embedded-set, link, list, embedded-map, link, list and many others...)
  • provide a base repository class
  • implementation of the persistence from the ODM to OrientDB

Utilities

Orient incapsulates also a few utilities for PHP developers: on of them is an implementation of Dijkstra's algorithm.

use Doctrine\OrientDB\Graph\Graph;
use Doctrine\OrientDB\Graph\Vertex;
use Doctrine\OrientDB\Graph\Algorithm\Dijkstra;

$graph = new Graph();

$rome = new Vertex('Rome');
$paris = new Vertex('Paris');
$london = new Vertex('London');

$rome->connect($paris, 2);
$rome->connect($london, 3);
$paris->connect($london, 1);

$graph->add($rome);
$graph->add($paris);
$graph->add($london);

$algorithm = new Dijkstra($graph);
$algorithm->setStartingVertex($rome);
$algorithm->setEndingVertex($london);

var_dump($algorithm->solve());

Tests

The test suite can be launched simply by executing phpunit from the root directory of the repository.

By default the suite does not perform integration tests to verify the correct behaviour of our implementation against a running instance of OrientDB.
Since integration tests are marked using the @group
annotation, they can be enabled by default via phpunit.xml by adding a comment to the integration group in the list of excluded groups or,
if you just want to execute them on a single execution basis, first load fixtures with this script

php ./test/Integration/fixtures/load.php

followeb by launching the suite with the additional --group argument:

phpunit --group __nogroup__,integration

It is also possible to generate a HTML report showing the code health of the library using PHP_CodeBrowser paired with the following dependencies
(in addition to phpunit):

  • phpcpd
  • phpdcd
  • phploc
  • phpmd
  • phpdepend
  • phpcb

Executing ./bin/report.sh from the root directory of the repository will generate the report in log/report/index.html.

Requirements

These are the requirements in order to use the library:

  • PHP >= 5.3.3
  • OrientDB >= 1.2.0

In order to launch the test suite PHPUnit 3.6 is required.

Tracker & software lifecycle

See: https://github.com/doctrine/orientdb-odm/issues

Further documentation

If you want to take a look at a fancy PHPDoc documentation you can use doxygen:

sudo apt-get install doxygen

and then use the script provided under the docs directory:

doxygen docs/orient.d

which will generate technical documentation under the folder docs/html.