1. Go to this page and download the library: Download betalabs/amazon-es-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
betalabs / amazon-es-php example snippets
use Aws\ElasticsearchService\ElasticsearchPhpHandler;
use Elasticsearch\ClientBuilder;
// Create a handler (with the region of your Amazon Elasticsearch Service domain)
$handler = new ElasticsearchPhpHandler('us-west-2');
// Use this handler to create an Elasticsearch-PHP client
$client = ClientBuilder::create()
->setHandler($handler)
->setHosts(['https://search-foo-3gn4utxfus5cqpn89go4z5lbsm.us-west-2.es.amazonaws.com:443'])
->build();
// Use the client as you normally would
$client->index([
'index' => $index,
'type' => $type,
'id' => $id,
'body' => [$key => $value]
]);
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;
use Aws\ElasticsearchService\ElasticsearchPhpHandler;
$provider = CredentialProvider::fromCredentials(
new Credentials('foo', 'bar', 'baz')
);
$handler = new ElasticsearchPhpHandler('us-west-2', $provider);