PHPackages                             jiangyunan/riak - 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. jiangyunan/riak

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

jiangyunan/riak
===============

Official Riak client for PHP

v1.0(4y ago)1181Apache-2.0PHPPHP &gt;=5.4CI failing

Since Jul 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jiangyunan/riak-php7)[ Packagist](https://packagist.org/packages/jiangyunan/riak)[ Docs](http://basho.com/riak/)[ RSS](/packages/jiangyunan-riak/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Riak Client for PHP 修改版
=======================

[](#riak-client-for-php-修改版)

支持 PHP7以上, protobuf修改为 Google 官方protobuf

示例
--

[](#示例)

官方示例，

### 对象

[](#对象)

```
use Basho\Riak;
use Basho\Riak\Node;
use Basho\Riak\Command;

$node = (new node\Builder)
    ->atHost('127.0.0.1')
    ->onPort(8087)
    ->build();
$riak = new Riak([$node], [], new Riak\Api\Pb());
$bucket = new Riak\Bucket("carnoc");

$key = "date.txt";
$location = new Riak\Location($key, $bucket);
```

### 写入

[](#写入)

对写入、读取的内容不再编码，无需设置`setContentEncoding`

```
$dateString = Date("H:i:s");

$dataObject = new Riak\RObject($dateString);
$dataObject->setContentType("text/plain");

$storeCommand = (new Command\Builder\StoreObject($riak))
    ->withObject($dataObject)
    ->atLocation($location)
    ->build();
$response = $storeCommand->execute();
```

### 读取

[](#读取)

```
$fetchCommand = (new Command\Builder\FetchObject($riak))
    ->atLocation($location)
    ->build();
$response = $fetchCommand->execute();

if($response->getCode() == 200){
    $dataObject = $response->getObject();
    $contentType = $dataObject->getContentType();
    $data = [
        "type" => $contentType,
        "data" => $dataObject->getData(),
    ];
} else {
    $data = [];
}
```

### 删除

[](#删除)

```
$deleteCommand = (new Command\Builder\DeleteObject($riak))
    ->atLocation($location)
    ->build();
$response = $deleteCommand->execute();

return ($response->getCode() == 204);
```

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

[](#installation)

### Dependencies

[](#dependencies)

- PHP 5.4+
- PHP Extensions: curl, json and openssl [protobuf](https://pecl.php.net/package/protobuf)
- Riak 2.1+

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

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

[![Packagist](https://camo.githubusercontent.com/d8da4291986d94a1be29ea7990149278227de47a57d52e2774c239a5b7a39cc0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626173686f2f7269616b2e7376673f6d61784167653d32353932303030)](https://packagist.org/packages/basho/riak)

**Riak PHP Client** is a library which makes it easy to communicate with [Riak](http://basho.com/riak/), an open source, distributed database that focuses on high availability, horizontal scalability, and *predictable*latency. This library communicates with Riak's HTTP interface using the cURL extension. If you want to communicate with Riak using the Protocol Buffers interface, use the [Official PHP PB Client](https://github.com/basho/riak-phppb-client). Both Riak and this library are maintained by [Basho Technologies](http://www.basho.com/).

To see other clients available for use with Riak visit our [Documentation Site](http://docs.basho.com/riak/latest/dev/using/libraries)

1. [Riak Client for PHP 修改版](#riak-client-for-php-%E4%BF%AE%E6%94%B9%E7%89%88)
    1. [Installation](#installation)
        1. [Dependencies](#dependencies)
2. [Riak Client for PHP](#riak-client-for-php)
    1. [Installation](#installation-1)
        1. [Dependencies](#dependencies-1)
        2. [Composer Install](#composer-install)
    2. [Documentation](#documentation)
        1. [Example Usage](#example-usage)
    3. [Contributing](#contributing)
        1. [An honest disclaimer](#an-honest-disclaimer)
    4. [Roadmap](#roadmap)
    5. [License and Authors](#license-and-authors)

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

[](#installation-1)

### Dependencies

[](#dependencies-1)

- PHP 5.4+
- PHP Extensions: curl, json and openssl \[required for security features\]
- Riak 2.1+
- [Composer PHP Dependency Manager](https://getcomposer.org/)

### Composer Install

[](#composer-install)

This library has been added to [Packagist](https://packagist.org/packages/basho/) to simplify the installation process. Run the following [composer](https://getcomposer.org/) command:

```
$ composer require "basho/riak": "3.0.*"
```

Alternately, manually add the following to your `composer.json`, in the `require` section:

```
"require": {
    "basho/riak": "3.0.*"
}
```

And then run `composer update` to ensure the module is installed.

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

[](#documentation)

- Master: [![Build Status](https://camo.githubusercontent.com/5fca5cfd2d6c7a5d184fbd076c9610161a75e8203020026ad5661227b08b87a8/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f626173686f2f7269616b2d7068702d636c69656e742e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/basho/riak-php-client)

A fully traversable version of the API documentation for this library can be found on [Github Pages](http://basho.github.io/riak-php-client).

### Example Usage

[](#example-usage)

Below is a short example of using the client. More substantial sample code is available [in examples](/examples).

```
// lib classes are included via the Composer autoloader files
use Basho\Riak;
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);

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

Contributing
------------

[](#contributing)

This repo's maintainers are engineers at Basho and we welcome your contribution to the project! You can start by reviewing [CONTRIBUTING.md](CONTRIBUTING.md) for information on everything from testing to coding standards.

### An honest disclaimer

[](#an-honest-disclaimer)

Due to our obsession with stability and our rich ecosystem of users, community updates on this repo may take a little longer to review.

The most helpful way to contribute is by reporting your experience through issues. Issues may not be updated while we review internally, but they're still incredibly appreciated.

Thank you for being part of the community! We love you for it.

Roadmap
-------

[](#roadmap)

- Current develop &amp; master branches contain feature support for Riak version 2.1+
- Add support for Riak TS Q2 2016

License and Authors
-------------------

[](#license-and-authors)

- Author: Christopher Mancini ()
- Author: Alex Moore ()
- Author: Luke Bakken ()

Copyright (c) 2015 Basho Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"). For more details, see [License](License).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1760d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/330a661d7f75764a413eac74a9d1962ab302cc8f264bf82325ea2045b6571ca2?d=identicon)[jiangyunan](/maintainers/jiangyunan)

---

Top Contributors

[![jiangyunan](https://avatars.githubusercontent.com/u/1539538?v=4)](https://github.com/jiangyunan "jiangyunan (4 commits)")

---

Tags

clientdatadatabasenosqldriverriakdatatypebashokvcrdt

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)

PHPackages © 2026

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