elastic / elasticsearch-php

Official PHP client for Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
MIT License
35 stars 970 forks source link

[8.0 alpha]PHP Fatal error: Uncaught Error: Class "Elastic\\Transport\\TransportBuilder" not found in /src/ClientBuilder.php:315 #1200

Closed chongshengdz closed 2 years ago

chongshengdz commented 2 years ago

[8.0 alpha]PHP Fatal error: Uncaught Error: Class "Elastic\Transport\TransportBuilder" not found in /src/ClientBuilder.php:315

ezimuel commented 2 years ago

@chongshengdz can you try using v8.0.0-RC1 ? Thanks.

chongshengdz commented 2 years ago

Many thanks for the reply. i will try it later today.

chongshengdz commented 2 years ago

@chongshengdz can you try using v8.0.0-RC1 ? Thanks.

same error message,maybe need to install the elastic-transport-php library?

chongshengdz commented 2 years ago

@chongshengdz can you try using v8.0.0-RC1 ? Thanks.

PHP Fatal error: Uncaught Error: Class "Composer\InstalledVersions" not found in /transport/src/Transport.php:439, referer:

chongshengdz commented 2 years ago

Connection could not be established.The client noticed that the server is not Elasticsearch and we do not support this unknown product× Read Timeout

ezimuel commented 2 years ago

@chongshengdz I released elastic-transport-php v8.0.0-rc4 and elasticsearch-php v8.0.0-rc2. In order to install these RC versions you need to install elastic-transport-php and after elasticsearch-php as follows:

composer require elastic/transport:8.0.0-rc4
composer require elasticsearch/elasticsearch:8.0.0-rc2

This will produce the following composer.json:

"require": {
    "elastic/transport": "8.0.0-rc4",
    "elasticsearch/elasticsearch": "8.0.0-rc2"
}

Regarding the error message The client noticed that the server is not Elasticsearch and we do not support this unknown product this means you are using a previous 7.x version of Elasticsearch server or a not supported product. Starting from version 8 the elasticsearch-php client supports only Elasticsearch 8+ server.

chongshengdz commented 2 years ago
composer require elasticsearch/elasticsearch:8.0.0-rc2

I did follow your above instruction. but the error still persist. PHP Fatal error: Uncaught Error: Class "Composer\InstalledVersions" not found in /vendor/elastic/transport/src/Transport.php:439 I am using elasticsearch version 8.1.0 elasticsearch-php v8.0.0-rc2 elastic-transport-php v8.0.0-rc4 php 8.0+

$this->client = \Elastic\Elasticsearch\ClientBuilder::create()->setHosts($host)->build(); is it correct?

chongshengdz commented 2 years ago

Composer version 1.10.22 2021-04-27 13:10:45 centos 7

chongshengdz commented 2 years ago

it works fine after upgrading to Composer 2.0+. the problem is due to i was using an old version of 1.0+. "Composer\InstalledVersions" is only available on Composer 2.0+.