PHP code example of mailerlite / laravel-elasticsearch
1. Go to this page and download the library: Download mailerlite/laravel-elasticsearch 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/ */
mailerlite / laravel-elasticsearch example snippets
// config/elasticsearch.php
$provider = \Aws\Credentials\CredentialProvider::instanceProfile();
$memoizedProvider = \Aws\Credentials\CredentialProvider::memoize($provider);
$credentials = $memoizedProvider()->wait();
...
'hosts' => [
[
'host' => env('ELASTICSEARCH_HOST', 'localhost'),
// For local development, the default Elasticsearch port is 9200.
// If you are connecting to an Elasticsearch instance on AWS, you probably want to set this to null
'port' => env('ELASTICSEARCH_PORT', 9200),
'scheme' => env('ELASTICSEARCH_SCHEME', null),
'user' => env('ELASTICSEARCH_USER', null),
'pass' => env('ELASTICSEARCH_PASS', null),
// If you are connecting to an Elasticsearch instance on AWS, you will need these values as well
'aws' => env('AWS_ELASTICSEARCH_ENABLED', false),
'aws_region' => env('AWS_REGION', ''),
'aws_key' => env('AWS_ACCESS_KEY_ID', ''),
'aws_secret' => env('AWS_SECRET_ACCESS_KEY', '')
'aws_credentials' => $credentials
],
],
// using injection:
public function handle(\Mailerlite\LaravelElasticsearch\Manager $elasticsearch)
{
$elasticsearch->ping();
}
// using application container:
$elasticSearch = $this->app('elasticsearch');