{"id":20002805,"url":"https://github.com/babenkoivan/elastic-client","last_synced_at":"2025-04-09T10:10:09.552Z","repository":{"id":51541404,"uuid":"217838906","full_name":"babenkoivan/elastic-client","owner":"babenkoivan","description":"The official PHP Elasticsearch client integrated with Laravel","archived":false,"fork":false,"pushed_at":"2024-06-18T06:54:56.000Z","size":57,"stargazers_count":52,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T08:11:16.915Z","etag":null,"topics":["client","elasticsearch","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babenkoivan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"ivanbabenko","custom":["https://paypal.me/babenkoi"]}},"created_at":"2019-10-27T10:32:34.000Z","updated_at":"2025-02-17T10:38:45.000Z","dependencies_parsed_at":"2024-11-13T09:15:14.514Z","dependency_job_id":null,"html_url":"https://github.com/babenkoivan/elastic-client","commit_stats":{"total_commits":47,"total_committers":1,"mean_commits":47.0,"dds":0.0,"last_synced_commit":"c3f016a1b33cf1e378fffb64f8aeed37be228234"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babenkoivan%2Felastic-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babenkoivan%2Felastic-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babenkoivan%2Felastic-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babenkoivan%2Felastic-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babenkoivan","download_url":"https://codeload.github.com/babenkoivan/elastic-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018061,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","elasticsearch","laravel","php"],"created_at":"2024-11-13T05:23:08.570Z","updated_at":"2025-04-09T10:10:09.518Z","avatar_url":"https://github.com/babenkoivan.png","language":"PHP","funding_links":["https://ko-fi.com/ivanbabenko","https://paypal.me/babenkoi"],"categories":[],"sub_categories":[],"readme":"# Elastic Client\n\n[![Latest Stable Version](https://poser.pugx.org/babenkoivan/elastic-client/v/stable)](https://packagist.org/packages/babenkoivan/elastic-client)\n[![Total Downloads](https://poser.pugx.org/babenkoivan/elastic-client/downloads)](https://packagist.org/packages/babenkoivan/elastic-client)\n[![License](https://poser.pugx.org/babenkoivan/elastic-client/license)](https://packagist.org/packages/babenkoivan/elastic-client)\n[![Tests](https://github.com/babenkoivan/elastic-client/workflows/Tests/badge.svg)](https://github.com/babenkoivan/elastic-client/actions?query=workflow%3ATests)\n[![Code style](https://github.com/babenkoivan/elastic-client/workflows/Code%20style/badge.svg)](https://github.com/babenkoivan/elastic-client/actions?query=workflow%3A%22Code+style%22)\n[![Static analysis](https://github.com/babenkoivan/elastic-client/workflows/Static%20analysis/badge.svg)](https://github.com/babenkoivan/elastic-client/actions?query=workflow%3A%22Static+analysis%22)\n[![Donate PayPal](https://img.shields.io/badge/donate-paypal-blue)](https://paypal.me/babenkoi)\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://ko-fi.com/ivanbabenko\" target=\"_blank\"\u003e\u003cimg src=\"https://ko-fi.com/img/githubbutton_sm.svg\" alt=\"Support the project!\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nThe official PHP Elasticsearch client integrated with Laravel.\n\n## Contents\n\n* [Compatibility](#compatibility)\n* [Installation](#installation) \n* [Configuration](#configuration)\n* [Usage](#usage)\n\n## Compatibility\n\nThe current version of Elastic Client has been tested with the following configuration:\n\n* PHP 8.2\n* Elasticsearch 8.x \n* Laravel 11.x\n\nIf your project uses older Laravel (or PHP) version check [the previous major version](https://github.com/babenkoivan/elastic-client/tree/v2.1.0#compatibility) of the package.\n\n## Installation\n\nThe library can be installed via Composer:\n\n```bash\ncomposer require babenkoivan/elastic-client\n```\n\n## Configuration\n\nTo change the client settings you need to publish the configuration file first:\n\n```bash\nphp artisan vendor:publish --provider=\"Elastic\\Client\\ServiceProvider\"\n```\n\nIn the newly created `config/elastic.client.php` file you can define the default connection name and describe multiple \nconnections using configuration hashes. You can read more about building the client from a configuration hash [here](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/node_pool.html#config-hash).\n\n```php\nreturn [\n    'default' =\u003e env('ELASTIC_CONNECTION', 'default'),\n    'connections' =\u003e [\n        'default' =\u003e [\n            'hosts' =\u003e [\n                env('ELASTIC_HOST', 'localhost:9200'),\n            ],\n            // configure basic authentication\n            'basicAuthentication' =\u003e [\n                env('ELASTIC_USERNAME'),\n                env('ELASTIC_PASSWORD'),\n            ],\n            // configure HTTP client (Guzzle by default)\n            'httpClientOptions' =\u003e [\n                'timeout' =\u003e 2,\n            ],\n        ],\n    ],\n];\n```\n\nIf you need more control over the client creation, you can create your own client builder:\n\n```php\nuse Elastic\\Elasticsearch\\ClientInterface;\nuse Elastic\\Client\\ClientBuilderInterface;\n\nclass MyClientBuilder implements ClientBuilderInterface\n{\n    public function default(): ClientInterface\n    {\n        // should return a client instance for the default connection \n    }\n    \n    public function connection(string $name): ClientInterface\n    {\n        // should return a client instance for the connection with the given name \n    }\n}\n```\n\nDo not forget to register the builder in your application service provider:\n\n```php\nclass MyAppServiceProvider extends Illuminate\\Support\\ServiceProvider\n{\n    public function register()\n    {\n        $this-\u003eapp-\u003esingleton(ClientBuilderInterface::class, MyClientBuilder::class);\n    }\n}\n```\n\n## Usage\n\nUse `Elastic\\Client\\ClientBuilderInterface` to get access to the client instance:\n\n```php\nnamespace App\\Console\\Commands;\n\nuse Elastic\\Elasticsearch\\ClientInterface;\nuse Elastic\\Client\\ClientBuilderInterface;\nuse Illuminate\\Console\\Command;\n\nclass CreateIndex extends Command\n{\n    protected $signature = 'create:index {name}';\n\n    protected $description = 'Creates an index';\n\n    public function handle(ClientBuilderInterface $clientBuilder)\n    {\n        // get a client for the default connection\n        $client = $clientBuilder-\u003edefault();\n        // get a client for the connection with name \"write\"\n        $client = $clientBuilder-\u003econnection('write');\n    \n        $client-\u003eindices()-\u003ecreate([\n            'index' =\u003e $this-\u003eargument('name')\n        ]);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabenkoivan%2Felastic-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabenkoivan%2Felastic-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabenkoivan%2Felastic-client/lists"}