neo4j-php/query-api
Composer 安装命令:
composer require neo4j-php/query-api
包简介
Easy to use class to run Cypher queries on the Query API
README 文档
README
Interact programmatically with Top Graph Technology
- Easy to start with, just build your client in one line and start running queries
- Use an intuitive API for smooth query execution
- Built and tested under close collaboration with the official Neo4j driver team
- Fully typed with Psalm and CS fixed for code quality
- Uses HTTP under the hood instead of bolt
- Small, lightweight, well maintained and fully tested codebase
Installation
You can install the package via Composer:
composer require neo4j-php/query-api
Client Installation
This client uses the HTTP protocol, make sure you have psr-7, psr-17, and psr-18 implementations included in your project. If you don't have any, you can install one of the many options via Composer:
composer require guzzlehttp/guzzle
NOTE: PSR-17 and PSR-18 are essential for HTTP client communication. Other compatible clients like Guzzle can also be used. * PSR auto-discovery will detect the installed HTTP client automatically.
Usage
Connecting to Neo4j
use Neo4j\QueryAPI\Neo4jQueryAPI; use Neo4j\QueryAPI\Objects\Authentication; $client = Neo4jQueryAPI::login('http://localhost:7474', Authentication::basic('username', 'password'));
Running a Query
$query = 'MATCH (n) RETURN n'; $result = $client->run($query); foreach ($result as $record) { print_r($record); }
Transactions
Begin a Transaction
$transaction = $client->beginTransaction();
Run a Query in a Transaction
$query = 'CREATE (n:Person {name: $name}) RETURN n'; $parameters = ['name' => 'John Doe']; $result = $transaction->run($query, $parameters);
Commit a Transaction
$transaction->commit();
Rollback a Transaction
$transaction->rollback();
Testing
To run the tests, execute the following command:
vendor/bin/phpunit
Cypher values and types map to these php types and classes:
| Cypher | PHP |
|---|---|
| List | * array |
| Integer | * int |
| Float | * float |
| Boolean | * bool |
| Null | * null |
| String | * string |
| Array | * array |
| Local DateTime | * string (will be upgraded in version 1.1) |
| Local Time | * string (will be upgraded in version 1.1) |
| Zoned DateTime | * string (will be upgraded in version 1.1) |
| Zoned Time | * string (will be upgraded in version 1.1) |
| Duration | * string (will be upgraded in version 1.1) |
| WGS 84 2D Point | Neo4j\QueryAPI\Objects\Point |
| WGS 84 3D Point | Neo4j\QueryAPI\Objects\Point |
| Cartesian 2D Point | Neo4j\QueryAPI\Objects\Point |
| Cartesian 3D Point | Neo4j\QueryAPI\Objects\Point |
| Map | * array |
| Node | Neo4j\QueryAPI\Objects\Node |
| Relationship | Neo4j\QueryAPI\Objects\Relationship |
| Path | Neo4j\QueryAPI\Objects\Relationship |
Diving deeper:
| Feature | Supported? |
|---|---|
| Authentication | Yes |
| Transaction | Yes |
| HTTP | Yes |
| Cluster | Partly * |
| Aura | Yes |
| Bookmarks | Yes |
| Bolt | No |
* Client side routing is only supported in the Neo4j driver
NOTE: It supports neo4j databases versions > 5.25 or Neo4j Aura (which has QueryAPI enabled.)
Contributing
Please see CONTRIBUTING.md for details.
Security
If you discover any security-related issues, please email security@nagels.tech instead of using the issue tracker.
Credits
- Created with ❤️ by Nagels
- Kiran Chandani,
- Pratiksha Zalte,
- Ghlen Nagels
License
The MIT License (MIT). Please see License File for more information.
neo4j-php/query-api 适用场景与选型建议
neo4j-php/query-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 neo4j-php/query-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 neo4j-php/query-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-03-12