0

I am a little confused as to how to go about this but basically I am trying to integrate Elastic Search into an existing mySQL database. I've done a bit of research and discovered a PHP Client called Elastica which makes it easier to work with Elastic Search. However I am having a bit of trouble installing it into my project so that I can use the library.

It recommends installing via Composer but my project does not use this so that is not an option. It also mentions using the spl_autoload_register( ) function. I'm not entirely sure how to go about that.

They provide code on their website:

function __autoload_elastica ($class) {
    $path = str_replace('\\', '/', substr($class, 1));

    if (file_exists('/var/www/' . $path . '.php')) {
        require_once('/var/www/' . $path . '.php');
    }
}
spl_autoload_register('__autoload_elastica');

I'm having difficulty understanding where to place this code. I've placed the Elastica library in C://wamp/www/myproject/includes/elastica so do I just place this code in my header and modify /var/www/ to match my location? Has anyone experience installing Elastica without composer? How did you go about doing it or is it easier to integrate composer with the project and do it that way?

I'm sorry if this question seems stupid, I'm only out of college and currently in a company that is between lead developers so I've literally no direction or no body to ask, I need some guidance on this issue. Any help is much appreciated.

Javacadabra
  • 5,578
  • 15
  • 84
  • 152
  • You should start using composer, as that is the standard way to go. It's easy once you managed to run the few commands and after that you need to include only one single item. Composer will also take care of updating the library and deal with it later. – Pentium10 Oct 21 '14 at 09:59
  • I have installed elasticsearch using apt-get in ubuntu, now no idea how to proceed as all sample questions need autoload.php to be included :( – Ashutosh Nigam Mar 03 '15 at 09:04

0 Answers0