PHPackages                             betalabs/amazon-es-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. betalabs/amazon-es-php

ActiveLibrary[Search &amp; Filtering](/categories/search)

betalabs/amazon-es-php
======================

Support for using IAM authentication with the official Elasticsearch PHP client

0.3.0(6y ago)013.8k—8.3%Apache-2.0PHP

Since Mar 20Pushed 4y agoCompare

[ Source](https://github.com/Betalabs/amazon-es-php)[ Packagist](https://packagist.org/packages/betalabs/amazon-es-php)[ RSS](/packages/betalabs-amazon-es-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

AWS Auth Elasticsearch-PHP Handler
==================================

[](#aws-auth-elasticsearch-php-handler)

[![Apache 2 License](https://camo.githubusercontent.com/cfbf637c43e838ff0e76ed9fe00ba711f3a40d8e2cedea1d323b2824354d3cd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a73712f616d617a6f6e2d65732d7068702e7376673f7374796c653d666c6174)](https://www.apache.org/licenses/LICENSE-2.0.html)[![Total Downloads](https://camo.githubusercontent.com/aed624daf893f9bfe2f6160a6bc0a68411c48ea5716c0ae01415410d4fcdbdc3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a73712f616d617a6f6e2d65732d7068702e7376673f7374796c653d666c6174)](https://packagist.org/packages/jsq/amazon-es-php)[![Author](https://camo.githubusercontent.com/297a2017c3c5d5b0f717bf17f2713cd12b5ba24945e861cf9af88e37d6bf50ce/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406a7265736b65772d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/jreskew)[![Build Status](https://camo.githubusercontent.com/71fe448b823c531bdfd393fed3cd683e4e0345b23c86063b494374d8a5e93e07/68747470733a2f2f7472617669732d63692e6f72672f6a65736b65772f616d617a6f6e2d65732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jeskew/amazon-es-php)

This package provides a signing handler for use with the official Elasticsearch-PHP (`elasticsearch/elasticsearch`) client. By default, the handler will load AWS credentials from the environment and send requests using a RingPHP cURL handler.

Basic Usage
-----------

[](#basic-usage)

Instances of `Aws\ElasticsearchService\ElasticsearchPhpHandler` are callables that fulfill Elasticsearch-PHP's handler contract. They can be passed to `Elasticsearch\ClientBuilder`'s `setHandler` method:

```
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]
]);
```

Using custom credentials
------------------------

[](#using-custom-credentials)

By default, the handler will attempt to source credentials from the environment as described [in the AWS SDK for PHP documentation](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html). To use custom credentials, pass in a [credential provider](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html#credential-provider):

```
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);
```

Using a custom HTTP handler
---------------------------

[](#using-a-custom-http-handler)

By default, the handler will use `Elasticsearch\ClientBuilder::defaultHandler()`to dispatch HTTP requests, but this is customizable via an optional constructor parameter. For example, this repository's tests use a custom handler to mock network traffic:

```
class ElasticsearchPhpHandlerTest extends \PHPUnit_Framework_TestCase
{
    public function testSignsRequestsPassedToHandler()
    {
        $toWrap = function (array $ringRequest) {
            $this->assertArrayHasKey('X-Amz-Date', $ringRequest['headers']);
            $this->assertArrayHasKey('Authorization', $ringRequest['headers']);
            $this->assertStringStartsWith(
                'AWS4-HMAC-SHA256 Credential=',
                $ringRequest['headers']['Authorization'][0]
            );

            return $this->getGenericResponse();
        };
        $handler = new ElasticsearchPhpHandler('us-west-2', null, $toWrap);

        $client = \Elasticsearch\ClientBuilder::create()
            ->setHandler($handler)
            ->build();

        $client->get([
            'index' => 'index',
            'type' => 'type',
            'id' => 'id',
        ]);
    }
    ...
}
```

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require jsq/amazon-es-php

```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~202 days

Recently: every ~222 days

Total

7

Last Release

2495d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5718a3a2c41de555560fde3279aaf122ce1584540c5f123e7661eaa3d79dba73?d=identicon)[diego-betalabs](/maintainers/diego-betalabs)

---

Top Contributors

[![jeskew](https://avatars.githubusercontent.com/u/705500?v=4)](https://github.com/jeskew "jeskew (7 commits)")[![diego-betalabs](https://avatars.githubusercontent.com/u/1482834?v=4)](https://github.com/diego-betalabs "diego-betalabs (1 commits)")[![d-melnyk](https://avatars.githubusercontent.com/u/35094114?v=4)](https://github.com/d-melnyk "d-melnyk (1 commits)")[![OlivierCoilland](https://avatars.githubusercontent.com/u/7049093?v=4)](https://github.com/OlivierCoilland "OlivierCoilland (1 commits)")[![rafaeltovar](https://avatars.githubusercontent.com/u/791726?v=4)](https://github.com/rafaeltovar "rafaeltovar (1 commits)")

---

Tags

clientsearchawselasticsearchiam

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/betalabs-amazon-es-php/health.svg)

```
[![Health](https://phpackages.com/badges/betalabs-amazon-es-php/health.svg)](https://phpackages.com/packages/betalabs-amazon-es-php)
```

###  Alternatives

[jsq/amazon-es-php

Support for using IAM authentication with the official Elasticsearch PHP client

9310.6M13](/packages/jsq-amazon-es-php)[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k178.3M943](/packages/elasticsearch-elasticsearch)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
