1. Go to this page and download the library: Download pgs-soft/elastic-om 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/ */
pgs-soft / elastic-om example snippets
use Pgs\ElasticOM\Annotation as ODM;
class Book
{
/**
* @var string
* @ODM\Id
* @ODM\Field(type="string")
*/
private $id;
/**
* @var Author
* @ODM\Field(type="nested", targetClass="AppBundle\Entity\Author")
*/
private $author;
/**
* @var string
* @ODM\Field(type="string")
*/
private $title;
// ...
}
use Pgs\ElasticOM\ElasticApi\ApiServiceFactory;
$api = ApiServiceFactory::create('localhost', '9200', 'elastic_om');
// creating index 'elastic_om'
$api->createIndex();
// creating type Book
$api->createType(Book::class);
// updating type Book
$api->updateType(Book::class);
// app/AppKernel.php
public function registerBundles()
{
$bundles = [
// ...
new Pgs\ElasticOM\Bridge\Symfony\ElasticOMBundle(),
// ...
];
}