stolfam / conf-storage-php
保存PHP对象的配置。
1.0.2
2021-11-04 13:51 UTC
Requires
- php: >= 7.4
README
保存PHP对象的配置。
安装
composer require stolfam/conf-storage-php
使用
$baseSaveDir = __DIR__ . "/your/path";
$namespace = "yourNamespace";
$confStorage = new ConfStorage($baseSaveDir, $namespace);
// your object implementing IConfigurable
$object = new TestObject();
// Save your object
$yourObjectId = "yourObjectId";
$confStorage->save($yourObjectId, $objcet);
// Load your object whenever you want
$yourObject = $confStorage->load($yourObjectId);
功能
完整性检查
当对象加载时,会对其进行检查,如果其哈希值正确且未被修改,则返回。否则返回null
,你可以检查$confStorage->errors
来获取错误信息。
签名
你可以使用你的签名/密码为每个对象签名
$baseSaveDir = __DIR__ . "/your/path";
$namespace = "yourNamespace";
$confStorage = new ConfStorage($baseSaveDir, $namespace);
$signature = "yourSignatureOrSecretPassword";
$confStorage->setSignature($signature);
它像密码一样工作。如果你有它,你可以读取对象。否则你将得到null
。
密码/签名不会被以明文形式存储。它们总是被哈希处理。
覆盖
请注意,当保存时,每个文件都会被覆盖。