PHP code example of socalnick / orchestrate-php-client
1. Go to this page and download the library: Download socalnick/orchestrate-php-client 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/ */
socalnick / orchestrate-php-client example snippets
use SocalNick\Orchestrate\Client;
$client = new Client('your-api-key');
use SocalNick\Orchestrate\Client;
$client = new Client('your-api-key', 'https://api.aws-eu-west-1.orchestrate.io/v0/');
use SocalNick\Orchestrate\KvPutOperation;
$kvPutOp = new KvPutOperation("first_collection", "first_key", json_encode(array("name" => "Nick")));
$kvObject = $client->execute($kvPutOp);
$ref = $kvObject->getRef(); // 741357981fd7b5cb
use SocalNick\Orchestrate\SearchAggregateOperation;
$searchOp = new SearchAggregateOperation("films", 'value.imdbRating:stats');
$searchResult = $client->execute($searchOp);
$min = $searchResult->getValue()['aggregates'][0]['statistics']['min']; // 5.9
$max = $searchResult->getValue()['aggregates'][0]['statistics']['max']; // 9.3
use SocalNick\Orchestrate\EventPostOperation;
$evPostOp = new EventPostOperation("films", "pulp_fiction", "comment", json_encode(array("message" => "This is my favorite movie!")));
$evPostResult = $client->execute($evPostOp); // instance_of SocalNick\Orchestrate\EventUpsertResult
use SocalNick\Orchestrate\EventPostOperation;
$evPostOp = new EventPostOperation("films", "pulp_fiction", "comment", json_encode(array("message" => "This is my favorite movie!")), 1395029140000);
$evPostResult = $client->execute($evPostOp); // instance_of SocalNick\Orchestrate\EventUpsertResult
use SocalNick\Orchestrate\EventFetchOperation;
$evFetchOp = new EventFetchOperation("films", "pulp_fiction", "comment", $evPostResult->getTimestamp(), $evPostResult->getOrdinal());
$evObject = $client->execute($evFetchOp);
$message = $evObject->getValue()['value']['message']; // This is my favorite movie!
use SocalNick\Orchestrate\EventPutOperation;
$evPutOp = new EventPutOperation("films", "pulp_fiction", "comment", json_encode(array("message" => "This is still my favorite movie!")), $evPostResult->getTimestamp(), $evPostResult->getOrdinal());
$evPutResult = $client->execute($evPutOp); // instance_of SocalNick\Orchestrate\EventUpsertResult
use SocalNick\Orchestrate\EventPutOperation;
$evPutOp = new EventPutOperation("films", "pulp_fiction", "comment", json_encode(array("message" => "Seriously, this is still my favorite movie!")), $evPostResult->getTimestamp(), $evPostResult->getOrdinal(), $evPutResult->getRef());
$evPutResult = $client->execute($evPutOp); // instance_of SocalNick\Orchestrate\EventUpsertResult
use SocalNick\Orchestrate\EventDeleteOperation;
$evDeleteOp = new EventDeleteOperation("films", "pulp_fiction", "comment", $evPutResult->getTimestamp(), $evPutResult->getOrdinal(), true);
$result = $client->execute($evDeleteOp); // true
use SocalNick\Orchestrate\EventDeleteOperation;
$evDeleteOp = new EventDeleteOperation("films", "pulp_fiction", "comment", $evPutResult->getTimestamp(), $evPutResult->getOrdinal(), true, $evPutResult->getRef());
$result = $client->execute($evDeleteOp); // true
use SocalNick\Orchestrate\EventListOperation;
$evListOp = new EventListOperation("films", "pulp_fiction", "comment");
$evListObject = $client->execute($evListOp);
$evListObject->count(); // 10
use SocalNick\Orchestrate\EventListOperation;
$evListOp = new EventListOperation("films", "pulp_fiction", "comment", 20);
$evListObject = $client->execute($evListOp);
$evListObject->count(); // 20
use SocalNick\Orchestrate\EventListOperation;
$evListOp = new EventListOperation("films", "pulp_fiction", "comment", 20, $startEvent, $afterEvent, $beforeEvent, $endEvent);
$evListObject = $client->execute($evListOp);
use SocalNick\Orchestrate\GraphPutOperation;
$graphPutOp = new GraphPutOperation("films", "the_godfather", "sequel", "films", "the_godfather_part_2");
$result = $client->execute($graphPutOp); // true
$graphPutOp = new GraphPutOperation("films", "the_godfather_part_2", "sequel", "films", "the_godfather_part_3");
$result = $client->execute($graphPutOp); // true
use SocalNick\Orchestrate\GraphFetchOperation;
$graphFetchOp = new GraphFetchOperation("films", "the_godfather", "sequel/sequel");
$graphObject = $client->execute($graphFetchOp);
$count = $graphObject->count(); // 1