2017 © Pedro Peláez
 

library blackbox

image

mnapoli/blackbox

  • Tuesday, June 5, 2018
  • by mnapoli
  • Repository
  • 3 Watchers
  • 15 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 10 Open issues
  • 15 Versions
  • 0 % Grown

The README.md


currentMenu: home

BlackBox

BlackBox is a storage library that abstracts backends and data transformation behind simple interfaces., (*1)

Build Status Latest Version, (*2)

Store data. "Where" and "how" can be decided later., (*3)

Experimental: this project is still at the state of experimentation. Use with caution., (*4)

Usage

The API is defined by interfaces and is extremely simple., (*5)

namespace BlackBox;

interface Storage extends Traversable
{
    public function get(string $id);
    public function set(string $id, $data) : void;
    public function remove(string $id) : void;
}

$storage->set('foo', 'Hello World!');

echo $storage->get('foo'); // Hello World!

foreach ($storage as $key => $item) {
    echo $key; // foo
    echo $item; // Hello World!
}

You can read all about those interfaces in the Interfaces documentation., (*6)

Features

BlackBox can store data in:, (*7)

  • files
  • database (MySQL, PostgreSQL, SQLite, Oracle, …) using Doctrine DBAL
  • PHP arrays (i.e. in memory)

Data can optionally be:, (*8)

  • stored in JSON
  • stored in YAML
  • encrypted with AES

Additionally a storage can be cached with another (e.g. cache a DB storage with a Redis or array storage)., (*9)

Backends

Backends are classes that implement Storage:, (*10)

  • FileStorage
  • DirectoryStorage
  • DatabaseTable
  • ArrayStorage

You can read all about backends in the Backends documentation., (*11)

Transformers

Transformers transform data before storage and after retrieval:, (*12)

  • JsonEncoder
  • YamlEncoder
  • ObjectArrayMapper
  • AesEncrypter

You can read all about transformers in the Transformers documentation., (*13)

// Encode the data in JSON
$storage = new JsonEncoder(
    // Store data in files
    new DirectoryStorage('some/directory')
);

$storage->set('foo', [
    'name' => 'Lebowski',
]);
// will encode it in JSON
// then will store it into a file

$data = $storage->get('foo');
// will read from the file
// then will decode the JSON

echo $data['name']; // Lebowski

License

BlackBox is released under the MIT license., (*14)

The Versions

24/09 2014
23/09 2014
23/09 2014

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires