承接 mnapoli/blackbox 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mnapoli/blackbox

Composer 安装命令:

composer require mnapoli/blackbox

包简介

README 文档

README

currentMenu home

BlackBox

BlackBox is a storage library that abstracts backends and data transformation behind simple interfaces.

Build Status Latest Version

Store data. "Where" and "how" can be decided later.

Experimental: this project is still at the state of experimentation. Use with caution.

Usage

The API is defined by interfaces and is extremely simple.

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.

Features

BlackBox can store data in:

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

Data can optionally be:

  • 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).

Backends

Backends are classes that implement Storage:

  • FileStorage
  • DirectoryStorage
  • DatabaseTable
  • ArrayStorage

You can read all about backends in the Backends documentation.

Transformers

Transformers transform data before storage and after retrieval:

  • JsonEncoder
  • YamlEncoder
  • ObjectArrayMapper
  • AesEncrypter

You can read all about transformers in the Transformers documentation.

// 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.

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固