IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Installation
editInstallation
editElasticsearch-php can be used starting from PHP 7.4. To install the library you need to use composer with the following command:
composer require elasticsearch/elasticsearch
If you don’t have composer you can install it as follows:
curl -s http://getcomposer.org/installer | php php composer.phar install
More information about Composer can be found at their website.
When you have installed elasticsearch-php you can start using it
with the Client
class. You can use the ClientBuilder
class to
create this object, as follows:
require 'vendor/autoload.php'; $client = Elasticsearch\ClientBuilder::create()->build();
+
Client instantiation is performed with a static helper function create()
. This
creates a ClientBuilder object, which helps you to set custom configurations.
When you are done configuring, call the build()
method to generate a Client
object. For further info, consult the Configuration section.