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"; ?>