1.0.1 2014-04-15 16:45 UTC


Build StatusScrutinizer Quality Score

Riak authentication provider for laravel


Add bach-pedersen/laravel-riak-auth to your composer.json like this:

"require": {
    "bach-pedersen/laravel-riak-auth": "dev-master"  


Host and port name for Riak should be configured in your app/config/database.php like this:

    // File: app/config/database.php
    'riak' => array(
        'host' => 'localhost',
        'port' => 8087

Remember php-riak uses riak protobuf interface and not the http interface, default port is 8087.

Also the service providers should be registered in your app/config/app.php file, like this:

    // File: app/config/app.php
    'providers' => array(

Last but not least Riak needs to be set as auth driver in app/config/auth.php, you can also set a Riak bucket name where the users and reminders should be stored.

    // File: app/config/auth.php
    return array(
        'driver' => 'riak',
        'bucket' => 'laravel.users',
        'model' => '\BachPedersen\LaravelRiakAuth\RiakUser',

        'reminder' => array(
            'bucket' => 'laravel.reminders',

Custom model

By default \BachPedersen\LaravelRiakAuth\RiakUser is used as user object.
It is possible to use a custom user class as model as well, to do that make sure your user class inherits from RiakUser and set your user class's fully qualified name in auth.php 'model'.

  • Your user class should overwrite deserializeFromArray and jsonSerialize if it has custom fields that needs to be saved/loaded from database.
  • Your user class should overwrite merge if you implement merging logic (if you modify users often this is recommended, since Riak is eventual consistent)

Riak configuration

AllowMult and Search needs to be enabled on the users and reminders buckets, so first make sure search that is enabled in riak config and secondly enable search and allowMult on the buckets by calling the incleded auth:bucket:init and auth:reminder:bucket:init artisan commands.

php artisan auth:bucket:init  
php artisan auth:reminder:bucket:init