PHP code example of kuzzleio / kuzzle-sdk

1. Go to this page and download the library: Download kuzzleio/kuzzle-sdk 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/ */

    

kuzzleio / kuzzle-sdk example snippets




use \Kuzzle\Kuzzle;
use \Kuzzle\Document;

$kuzzle = new Kuzzle('localhost');
$collection = $kuzzle->collection('bar', 'foo');

$firstDocument = new Document($collection, 'john', ['name' => 'John', 'age' => 42]);
$secondDocument = new Document($collection, 'michael', ['name' => 'Michael', 'age' => 36]);

$firstDocument->save(['refresh' => 'wait_for']);
$secondDocument->save(['refresh' => 'wait_for']);

$result = $collection->search(['sort' => [['age' => 'asc']]]);
foreach ($result->getDocuments() as $document) {
    $content = $document->getContent();
    echo "Name: {$content['name']}, age: {$content['age']}\n";
}

php ./vendor/bin/phpcs -p -n --standard=PSR2 src
php ./vendor/bin/phpunit