lavamusic/elasticsearch-php-client

1.0.1-alpha 2022-04-19 02:44 UTC

This package is not auto-updated.

Last update: 2024-04-16 11:55:40 UTC


README

Latest Stable Version Total Downloads

This is the PHP client for Elasticsearch, which is implemented with reference to the official PHP client of Elasticsearch.

The main purpose of this component is to facilitate users to operate es in the swoole related frameworks.

The cURL request driver layer is implemented using the swoole coroutine client. You can use it in swoole related frameworks (eg: EasySwoole, Hyperf, Swoft, IMIPHP, Mix-PHP, etc.).

Contents

Getting started 🐣

Using this client assumes that you have an Elasticsearch server installed and running.

You can install the client in your PHP project using composer:

composer require lavamusic/elasticsearch-php-client "dev-main"

After the installation you can connect to Elasticsearch using the ClientBuilder class. For instance, if your Elasticsearch is running on localhost:9200 you can use the following code:

<?php

use LavaMusic\Elasticsearch\ClientBuilder;

$client = ClientBuilder::create()
    ->setHosts(['localhost:9200'])
    ->build();

// Info API
$response = $client->info();

echo $response['version']['number']; // 7.10.1

License 📗

Apache License 2.0