PHP client not working

I want to use the php client. E installed it using Composer, like shown in the tutorial here: Installation | Elasticsearch PHP Client [7.16] | Elastic

Composer creates the composer.lock file and install the dependencies in the vendor folder.
However when I try to use the client it doesn't work. For example this code. The first echo is shown but then nothing else, including the second echo. I can make querrys using curl in my terminal so the Elasticsearch is running and I also have an index.

I would be very gratefull for your help. Thank you a lot.

echo "test1";
require 'vendor/autoload.php';
$hosts = [

$client = ClientBuilder::create()

$params = [
    'index' => 'my_index',
    'id'    => 'my_id',
    'body'  => ['testField' => 'abc']

$response = $client->index($params);
echo "test2";

Is it https or http?

I now tried with both, makes no difference. Also tried

$hosts = [ '' ];

Could you share the full Elasticsearch logs?

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