1. Go to this page and download the library: Download ppshobi/psonic 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/ */
ppshobi / psonic example snippets
$ingest = new Psonic\Ingest(new Psonic\Client('localhost', 1491, 30));
$control = new Psonic\Control(new Psonic\Client('localhost', 1491, 30));
$ingest->connect('SecretPassword1');
$control->connect('SecretPassword1');
echo $ingest->push('messagesCollection', 'defaultBucket', "1234","hi Shobi how are you?")->getStatus(); // OK
echo $ingest->push('messagesCollection', 'defaultBucket', "1235","hi are you fine ?")->getStatus(); //OK
echo $ingest->push('messagesCollection', 'defaultBucket', "1236","Jomit? How are you?")->getStatus(); //OK
echo $control->consolidate(); // saves the data to disk
$ingest->disconnect();
$control->disconnect();
$search = new Psonic\Search(new Psonic\Client('localhost', 1491, 30));
$search->connect('SecretPassword1');
var_dump($search->query('messagesCollection', 'defaultBucket', "are")); // you should be getting an array of object keys which matched with the term "are"
$search->disconnect();
$search = new Psonic\Search(new Psonic\Client('localhost', 1491, 30));
$search->connect('SecretPassword1');
var_dump($search->suggest('messagesCollection', 'defaultBucket', "sho")); // you should be getting an array of terms which matched the term "sho". Considering previous example and it should output "shobi"
$search->disconnect();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.