webgriffe / amp-elasticsearch
Amp 基础上的非阻塞 ElasticSearch 客户端
2.0.0
2022-09-30 15:52 UTC
Requires
- php: ~7.4.0|~8.0.0
- ext-json: *
- amphp/amp: ^2.1
- amphp/http-client: ^4.5
Requires (Dev)
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-08-29 05:00:59 UTC
README
webgriffe/amp-elasticsearch
是一个用于与 amp
并发框架一起使用的非阻塞 ElasticSearch 客户端。
所需的 PHP 版本
- PHP 7.4
- PHP 8.0
安装
composer require webgriffe/amp-elasticsearch
使用方法
只需创建一个客户端实例并调用其公共方法,这些方法返回承诺
Loop::run(function () { $client = new Webgriffe\AmpElasticsearch\Client('http://my.elasticsearch.test:9200'); yield $this->client->createIndex('myindex'); $response = yield $this->client->indexDocument('myindex', '', ['testField' => 'abc']); echo $response['result']; // 'created' });
有关其他使用示例,请参阅 tests/Integration/ClientTest.php
。
所有客户端方法在成功的情况下返回 ElasticSearch REST API 响应的数组表示,或者在出错的情况下返回 Webgriffe\AmpElasticsearch\Error
。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 support@webgriffe.com
联系我们,而不是使用问题跟踪器。
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 LICENSE
。