avinashjoshi/cakephp-mapstore

MapStore - A Key Value store for CakePHP

dev-master 2015-12-09 14:15 UTC

This package is not auto-updated.

Last update: 2024-10-30 16:53:23 UTC


README

Software License Build Status Coverage Status

MapStore is a key-value store plugin for CakePHP framework. It is inspired by other key-value store projects.

Installation

The easiest & recommended way to install MapStore is via composer. Run the following command:

composer require avinashjoshi/cakephp-mapstore

After that you should load the plugin in your app editing config/bootstrap.php:

Plugin::load('MapStore');

After loading the plugin you need to migrate the tables for the plugin using:

bin/cake migrations migrate -p MapStore

Configuration

Configuration allows to specify if the value shoud be encrypted or not.

  • encrypt (required/optional): Set to false if you would like to disable encryption (Default is true).
  • key (required/optional): you can specify a key to be used by Security class to encrypt/decrypt value.
  • salt (required/optional): you can specify a salt to be used by Security class to encrypt/decrypt value.

key and salt can also be set globally by adding them to CakePHP's application configuration at app.php:

<?php
return [
    'Security' => [
        'salt' => 'some long & random salt',
        'key' => 'some long & random key'
    ]
];

You can grab a good pair of key and salt at Random Key Generator.

Basic Usage

<?php
use MapStore\Store\MapStore;

$store = MapStore::load('store_1');

$store->set('name', 'Avinash Joshi');
$store->get('name'); // Returns 'Avinash Joshi'
$store->delete('name');
$store->flush();

More Examples

// Load the databases without database encryption
$store_2 = MapStore::load('store_2', ['encrypt' => false]);

Support

Feel free to open an issue if you need help or have ideas to improve this plugin.

Contributing

Contributions and Pull Requests are always more than welcome!