neoan3-apps / file-away
用于测试、模拟、点击测试样本和原型设计的简单文件“数据库”
v1.0.0
2020-07-25 01:13 UTC
Requires
- php: ^7.4
- ext-json: *
Requires (Dev)
- phpunit/phpunit: 9.2.6
This package is auto-updated.
Last update: 2024-08-25 11:23:29 UTC
README
fileAway 伪数据库
测试、模拟、存储、展示,快速开发示例、模拟API和应用。
此“数据库”解决方案旨在快速开发,不建议在生产环境中使用。如果要在生产环境中使用,请考虑以下事项
- json文件的存储位置是否安全?(例如:通过apache中的.htaccess进行保护)
- 我是否需要可扩展性或处理更大数据集?(如果是:这不是您生产环境的解决方案!)
它用于什么?
是否曾需要快速搭建API?是否需要为单元测试提供一些测试数据?是否想要快速创建一个原型?这个“数据库”就是为您准备的。
安装
composer require neoan3-apps/file-away
使用
$db = new \Neoan3\Apps\FileAway('storage.json'); // add entry to new or existing entity $db->setEntity('articles') // set current entity ->add(['title'=>'demo post', 'content' => 'such text']) // add entry to entity ->save() // write to db // list all entries (NOTE: we assume that the entity is still set) foreach($db->find() as $post) { echo $post->title . "<br>"; } // find one echo $db->findOne(['title' => 'demo post'])->content;
协作
请随意添加问题、拉取请求和建议