PHP code example of isswp101 / elasticsearch-eloquent
1. Go to this page and download the library: Download isswp101/elasticsearch-eloquent 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/ */
isswp101 / elasticsearch-eloquent example snippets
use Isswp101\Persimmon\Models\BaseElasticsearchModel;
use Isswp101\Persimmon\Persistence\Persistence;
use Isswp101\Persimmon\Contracts\PersistenceContract;
class Product extends BaseElasticsearchModel
{
protected string $index = 'index';
protected string|null $type = 'type'; // optional
// If you have a pre-configured Elasticsearch client you can pass it here (optional)
public function createPersistence(): PersistenceContract
{
return new Persistence($client);
}
}