PHP code example of basho / riak-pb

1. Go to this page and download the library: Download basho/riak-pb 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-pb example snippets


// lib classes are e Basho\Riak\Api\Pb;
use 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, [], new Pb());

// 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($command);

// Retrieve the Location of our newly stored object from the Response object
$object_location = $response->getLocation();