jc-it/secrets
Composer 安装命令:
composer require jc-it/secrets
包简介
Secrets storage
README 文档
README
This package provides secret storage.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require jc-it/secrets
or add
"jc-it/secrets": "^<latest version>"
to the require section of your composer.json file.
Configuration
It is recommended to use this package only in configuration files before your application is loaded, this way they won't be dumped by your application on chrashes or something unexpected.
$secrets = new \JCIT\secrets\Secrets( new \JCIT\secrets\storages\Chained( new \JCIT\secrets\storages\Cache(getenv()), new \JCIT\secrets\storages\Json('/run/env.json'), new \JCIT\secrets\storages\Filesystem(__DIR__ . '/secrets'), ) );
Note that the order in the Chained storage does matter, wherever a secret is found first that value will be returned.
Usage
After initialization, just call the following code:
$secrets->get('<secret>', '<optional default value>');
To be sure the secret is set use:
$secrets->getAndThrowOnNull('<secret>');
Extension
In order to implement your own storage, just extend the \JCIT\secrets\interfaces\StorageInterface.
TODO
- Write extractor based on https://github.com/JC-IT/yii2-secrets/blob/master/src/actions/Extract.php
Credits
统计信息
- 总下载量: 49
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-12