We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

ElasticSearch PHP client

How to connect to the project on the Phalcon php ElasticSearch PHP client from nervetattoo/elasticsearch

I'm a newbie. Phalcon PHP Installed according to the instructions. Took a typical example of the structure of the project Phalcon MVC Examples -> simple-volt. Now I want to take opportunity work with ElasticSearch server via ElasticSearch ElasticSearch PHP client. But I can not understand how to do it. How do I connect it to the project. Help to understand please.

edited May '14

Did you install Composer and the ElasticSearch PHP client? If not do these steps

Install composer in your project root. curl -s https://getcomposer.org/installer | php

Create composer.json in your project root containing:

    "require" : {
        "nervetattoo/elasticsearch" : ">=2.0"

Run ./composer.phar install

That phar file will check your composer.json file for libraries to download to the vendor folder

In your index.php of Phalcon project paste this

require '../vendor/autoload.php';

That autoload.php is from composer which registers the elasticsearch php client and other libraries. Check to see if the path of autoload.php is properly set Now you can use the class \ElasticSearch\Client in the whole of your project. Example in your indexAction

public function indexAction(){
    $es = new \ElasticSearch\Client::connection('');