Elasticsearch-PHP requires cURL, or a custom HTTP handler

I try to connect Elasticsearch from php with Elasticsearch-php Library.
But it notices

127.0.0.1:43202 [500]: GET /main.php?q=a - Uncaught RuntimeException: Elasticsearch-PHP requires cURL, or a custom HTTP handler. in /home/dell/Desktop/TKTT/SearchInformation/search_machine/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:239

This is my code:

require "vendor/autoload.php";
$hosts = [
    [
        'host'=>'localhost',
        'port'=>'9200',
        'scheme'=>'http',
        'user'=>'elastic',
        'pass'=>'admin1234'
    ]
];
$defaultHandler = Elasticsearch\ClientBuilder::defaultHandler();
$client = Elasticsearch\ClientBuilder::create()->setHosts($hosts)->setHandler($defaultHandler)->build();
$indices = $client->cat()->indices();
var_dump($indices);

I don't know how to handle it. Someone please help me!!!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.