commentar/json-storage
Composer 安装命令:
composer require commentar/json-storage
包简介
This storage mechanism requires no database, but rather stores the data encoded in the JSON format on the filesystem.
README 文档
README
Storage mechanism for the Commentar project. This storage mechanism requires no database, but rather stores the data encoded in the JSON format on the filesystem.
This should only be used for development purposes to have a portable way of introducing some persistent storage. It should never be used in production.
Installation
Add the storage mechanism to the project's composer.json file:
"require": {
"commentar/json-storage": "0.0.*",
}
Add the default admin user in the /data/users.json file:
{
"autoincrement": 1,
"users": {
"1": {
"id": 1,
"username": "PeeHaa",
"password": "$2y$14$Usk4vuNbzowQihbscOZjcu6RRzPBK3zIn79F8wn.bjczbElrqzbJu",
"email": "your@mail.com",
"isHellbanned": false,
"isAdmin": true
}
}
}
The password should be hashed using PHP's native password hashing function (password_hash()). The easiest way to generate the password hash is by either using this service or by manually running the password hashing function: echo password_hash('Your super secret password', PASSWORD_DEFAULT, ['cost' => 14]);.
To start using the storage you will have to start using the provided datamapper factory by this library. An example of retrieving the comment tree of a thread is:
$domainObjectFactory = new \Commentar\DomainObject\Factory();
$datamapperFactory = new \Commentar\Storage\Json\Factory(__DIR__ . '/vendor/commentar/json-storage/data');
$commentService = new \Commentar\Service\Comment($domainObjectFactory, $datamapperFactory);
$commentTree = $commentService->getTree(1);
统计信息
- 总下载量: 84
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-09-11