PHP code example of basho / riak
1. Go to this page and download the library: Download basho/riak 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/ */
basho / riak example snippets
// lib classes are e Basho\Riak\Node;
use Basho\Riak\Command;
// define the connection info to our Riak nodes
$nodes = (new Node\Builder)
->onPort(10018)
->buildCluster(['riak1.company.com', 'riak2.company.com', 'riak3.company.com',]);
// instantiate the Riak client
$riak = new Riak($nodes);
// build a command to be executed against Riak
$command = (new Command\Builder\StoreObject($riak))
->buildObject('some_data')
->buildBucket('users')
->build();
// Receive a response object
$response = $command->execute();
// Retrieve the Location of our newly stored object from the Response object
$object_location = $response->getLocation();