PHP client not working

Hello,
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.

<?php
echo "test1";
require 'vendor/autoload.php';
$hosts = [
    'https://localhost:9200' 
];

$client = ClientBuilder::create()
                    ->setHosts($hosts)
                    ->build();

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

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

Is it https or http?

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

$hosts = [ '127.0.0.1:9200' ];

Could you share the full Elasticsearch logs?

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