PHPackages                             php-riak/riak-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. php-riak/riak-client

ActiveLibrary[Database &amp; ORM](/categories/database)

php-riak/riak-client
====================

PHP Riak Client for PHP 5.4

v1.0.0-alpha7(9y ago)722.3k↓100%4[5 issues](https://github.com/php-riak/riak-client/issues)3MITPHPPHP &gt;=5.4.0

Since Mar 31Pushed 9y ago5 watchersCompare

[ Source](https://github.com/php-riak/riak-client)[ Packagist](https://packagist.org/packages/php-riak/riak-client)[ Docs](http://github.com/php-riak/riak-client)[ RSS](/packages/php-riak-riak-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (10)Versions (9)Used By (3)

Riak Client for PHP
===================

[](#riak-client-for-php)

[![Build Status](https://camo.githubusercontent.com/53f6f9b00b59945881a0c026c54cf55d42a8c1d7117191029b80896a7c3ff9dd/68747470733a2f2f7472617669732d63692e6f72672f7068702d7269616b2f7269616b2d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-riak/riak-client)[![Coverage Status](https://camo.githubusercontent.com/864452c58dd520dbbc9aa42c697d1798c1e339e393f6eca14937bab84ddc3258/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f7068702d7269616b2f7269616b2d636c69656e742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/php-riak/riak-client?branch=master)

A PHP client for [Riak](http://basho.com/riak/).

Installation
------------

[](#installation)

Run the following `composer` command:

```
$ composer require "php-riak/riak-client"
```

Documentation
-------------

[](#documentation)

API documentation for this library can be found on [readthedocs](http://riak-client.readthedocs.org/en/latest/)

Overview
--------

[](#overview)

Getting started with the php riak client.
-----------------------------------------

[](#getting-started-with-the-php-riak-client)

The easiest way to get started with the client is using a `RiakClientBuilder` :

```
use Riak\Client\RiakClientBuilder;

$builder = new RiakClientBuilder();
$client  = $builder
    ->withNodeUri('proto://192.168.1.1:8087')
    ->withNodeUri('proto://192.168.1.2:8087')
    ->withNodeUri('proto://192.168.1.3:8087')
    ->build();
```

Once you have a $client, commands from the `Riak\Client\Command*` namespace are built then executed by the client.

Some basic examples of building and executing these commands is shown below.

Getting Data In
---------------

[](#getting-data-in)

```
use Riak\Client\Command\Kv\StoreValue;
use Riak\Client\Core\Query\RiakObject;
use Riak\Client\Core\Query\RiakLocation;
use Riak\Client\Core\Query\RiakNamespace;

$object    = new RiakObject();
$namespace = new RiakNamespace('bucket_type', 'bucket_name');
$location  = new RiakLocation($namespace, 'object_key');

$object->setValue('[1,1,1]');
$object->setContentType('application/json');

// store object
$store    = StoreValue::builder($location, $object)
    ->withPw(1)
    ->withW(2)
    ->build();

$client->execute($store);
```

Getting Data Out
----------------

[](#getting-data-out)

```
use Riak\Client\Command\Kv\FetchValue;
use Riak\Client\Core\Query\RiakObject;
use Riak\Client\Core\Query\RiakLocation;
use Riak\Client\Core\Query\RiakNamespace;

$namespace = new RiakNamespace('bucket_type', 'bucket_name');
$location  = new RiakLocation($namespace, 'object_key');

// fetch object
$fetch  = FetchValue::builder($location)
    ->withNotFoundOk(true)
    ->withR(1)
    ->build();

$result = $client->execute($fetch);
$object = $result->getValue();
```

Removing Data
-------------

[](#removing-data)

```
use Riak\Client\Command\Kv\DeleteValue;
use Riak\Client\Core\Query\RiakObject;
use Riak\Client\Core\Query\RiakLocation;
use Riak\Client\Core\Query\RiakNamespace;

$namespace = new RiakNamespace('bucket_type', 'bucket_name');
$location  = new RiakLocation($namespace, 'object_key');

// delete object
$delete  = DeleteValue::builder($location)
    ->withPw(1)
    ->withW(2)
    ->build();

$this->client->execute($delete);
```

Merging siblings
----------------

[](#merging-siblings)

Siblings are an important feature in Riak, for this purpose we have the interface `Riak\Client\Resolver\ConflictResolver`, you implement this interface to resolve siblings into a single object.

Below is a simple example that will just merge the content of siblings :

```
use \Riak\Client\Resolver\ConflictResolver;
use \Riak\Client\Core\Query\RiakObject;
use \Riak\Client\Core\Query\RiakList;

class MySimpleResolver implements ConflictResolver
{
    /**
     * {@inheritdoc}
     */
    public function resolve(RiakList $siblings)
    {
        $result  = new MyDomainObject();
        $content = "";

        /** @var $object \MyDomainObject */
        foreach ($siblings as $object) {
            $content .= $object->getValue();
        }

        $result->setValue($content);

        return $result;
    }
}

// register your resolver during the application start up
/** @var $builder \Riak\Client\RiakClientBuilder */
$client = $builder
    ->withConflictResolver('MyDomainObject' new MySimpleResolver())
    ->withNodeUri('http://localhost:8098')
    ->build();

// fetch the object and resolve any possible conflict
$namespace = new RiakNamespace('bucket_type', 'bucket_name');
$location  = new RiakLocation($namespace, 'object_key');
$fetch     = FetchValue::builder($location)
    ->withNotFoundOk(true)
    ->withR(1)
    ->build();

/** @var $domain \MyDomainObject */
$result = $client->execute($fetch);
$domain = $result->getValue('MyDomainObject');
```

### Performance

[](#performance)

This library is faster than most riak clients written in php, It is about 50% percent faster is some cases, mostly because it uses protocol buffer and and iterators every where it is possible.

For more details and riak clients performance comparison see :

### Unit &amp; Integration Tests

[](#unit--integration-tests)

We want to ensure that all code that is included in a release has proper coverage with unit tests. It is expected that all pull requests that include new classes or class methods have appropriate unit tests included with the PR.

#### Running Tests

[](#running-tests)

Before running the functional tests set up your riak cluster:

- Create and activate the following types :

```
riak-admin bucket-type create counters '{"props":{"datatype":"counter"}}'
riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
riak-admin bucket-type create sets '{"props":{"datatype":"set"}}'
riak-admin bucket-type activate counters
riak-admin bucket-type activate maps
riak-admin bucket-type activate sets

```

- Enable search capabilities in your `riak.conf`:

```
search = on

```

We also expect that before submitting a pull request, that you have run the tests to ensure that all of them continue to pass after your changes.

To run the tests, clone this repository and run `composer update` from the repository root, then you can execute all the tests by simply running `php vendor/bin/phpunit`.

- To execute tests, run `./vendor/bin/phpunit`
- To check code standards, run `./vendor/bin/phpcs -p --extensions=php  --standard=ruleset.xml src`

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance6

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~107 days

Recently: every ~157 days

Total

7

Last Release

3411d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23188f97766175f33828c3cb9e9d1700ba2d73bca7e99739f370a1771deb700a?d=identicon)[FabioBatSIlva](/maintainers/FabioBatSIlva)

---

Top Contributors

[![FabioBatSilva](https://avatars.githubusercontent.com/u/588172?v=4)](https://github.com/FabioBatSilva "FabioBatSilva (119 commits)")[![s2x](https://avatars.githubusercontent.com/u/196585?v=4)](https://github.com/s2x "s2x (5 commits)")[![malkusch](https://avatars.githubusercontent.com/u/1623984?v=4)](https://github.com/malkusch "malkusch (2 commits)")[![RickvdP](https://avatars.githubusercontent.com/u/1748084?v=4)](https://github.com/RickvdP "RickvdP (1 commits)")[![robocoder](https://avatars.githubusercontent.com/u/922051?v=4)](https://github.com/robocoder "robocoder (1 commits)")

---

Tags

clientdatabasenosqldriverriak

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/php-riak-riak-client/health.svg)

```
[![Health](https://phpackages.com/badges/php-riak-riak-client/health.svg)](https://phpackages.com/packages/php-riak-riak-client)
```

###  Alternatives

[basho/riak

Official Riak client for PHP

159246.7k7](/packages/basho-riak)[datastax/php-driver

DataStax PHP Driver for Apache Cassandra

437521.5k19](/packages/datastax-php-driver)[mroosz/php-cassandra

A pure-PHP client for Apache Cassandra and ScyllaDB with support for CQL binary protocol v3, v4 and v5 (Cassandra 2.1+ incl. 3.x-5.x; ScyllaDB 6.2 and 2025.x), synchronous and asynchronous APIs, prepared statements, batches, result iterators, object mapping, SSL/TLS, and LZ4 compression.

205.6k2](/packages/mroosz-php-cassandra)[tbolier/php-rethink-ql

A clean and solid RethinkDB driver for PHP.

5211.7k](/packages/tbolier-php-rethink-ql)[cubettech/lacassa

Cassandra based query builder for laravel.

358.5k](/packages/cubettech-lacassa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
