mailerlite / laravel-elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.
MIT License
918 stars 187 forks source link

Call to undefined function Aws\default_http_handler() #61

Closed diggersworld closed 5 years ago

diggersworld commented 5 years ago

Running into the following error when trying to work with AWS. If I instead use a local Elasticsearch connection everything works as expected.

I'm using elasticsearch/elasticsearch@v6.7.0 and cviebrock/laravel-elasticsearch@3.5.1. I've tried various other versions too but still hit the same issue.

Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined function Aws\default_http_handler() at /www/sites/suru-partners/countryside-classroom/vendor/cviebrock/laravel-elasticsearch/src/Factory.php:93

    89| 
    90|         foreach ($config['hosts'] as $host) {
    91|             if (isset($host['aws']) && $host['aws']) {
    92|                 $clientBuilder->setHandler(function(array $request) use ($host) {
  > 93|                     $psr7Handler = \Aws\default_http_handler();
    94|                     $signer = new \Aws\Signature\SignatureV4('es', $host['aws_region']);
    95|                     $request['headers']['Host'][0] = parse_url($request['headers']['Host'][0])['host'];
    96| 
    97|                     // Create a PSR-7 request from the array passed to the handler

Exception trace:

  1   Cviebrock\LaravelElasticsearch\Factory::Cviebrock\LaravelElasticsearch\{closure}()
      /www/sites/suru-partners/countryside-classroom/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:202

  2   Elasticsearch\Connections\Connection::Elasticsearch\Connections\{closure}(Object(Elasticsearch\Connections\Connection), Object(Elasticsearch\Transport), [])
      /www/sites/suru-partners/countryside-classroom/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:177
diggersworld commented 5 years ago

I gather I need to install either of these packages: https://packagist.org/packages/aws/aws-sdk-php https://packagist.org/packages/cviebrock/laravel-elasticsearch?query=aws

cviebrock commented 5 years ago

I just updated the docs for this. Yes, you will need to do:

composer require aws/aws-sdk-php:^3.80