sinevia/laravel-vault
Composer 安装命令:
composer require sinevia/laravel-vault
包简介
A vault implementation for Laravel
README 文档
README
Vault - a secure value storage (data-at-rest) implementation for Laravel. It can be used directly, or attached to Laravel models. When attached to models it stores the values of the attributes securely in the Vault's table. The attributes in the model's table only contain the corresponding identifiers referencing the Vault's table.
Installation
composer require sinevia/laravel-vault
Table Schema
The following schema is used for the database.
| Vault | |
|---|---|
| Id | String, UniqueId |
| Value | Long Text |
| CreatedAt | DateTime |
| DeletedAt | DateTime |
| UpdatedAt | DateTime |
How to Use
1. Migrations
- 1.1. Add the migration file to your database/migrations directory
<?php
class VaultTablesCreate extends Illuminate\Database\Migrations\Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Sinevia\Vault\Models\Vault::tableCreate();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Sinevia\Vault\Models\Vault::tableDelete();
}
}
- 1.2. Run the migrations to create the Vault's table
php artisan migrate
2. Using Vault Directly
- 2.1 Store a value to the vault. If successful, will return the Vault id, that the value was securely stored under
$vaultId = \Sinevia\Models\Vault::storeValue($value, $password);
- 2.2 Retrieving the value using the Vault id it was stored under, (see the example above).
$value = \Sinevia\Model\Vault::retrieveValue($vaultId, $password);
3. Using Vault with Models
- 3.1. Vault Key
Create a new class app/Helpers/App with method vaultKey. The function should return a string with the key for securing your values. Do not lose your key, or you will not be able to restore your values
- 3.2. Add the VaultAttribute trait to the model
use \Sinevia\Vault\VaultAttributeTrait;
- 3.3. Specify the attributes to be used with Vault
class ExampleModel {
use \Sinevia\Vault\VaultAttributeTrait;
public function getUsernameAttribute($value) {
return $this->getVaultAttribute($value);
}
public function setUsernameAttribute($value) {
return $this->setVaultAttribute('Username', $value);
}
}
- 3.4. Use the vaulted attributes
$exampleModel->Username = 'test';
$exampleModel->save();
sinevia/laravel-vault 适用场景与选型建议
sinevia/laravel-vault 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 235 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 07 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「vault」 「sinevia」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sinevia/laravel-vault 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sinevia/laravel-vault 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sinevia/laravel-vault 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An easy Laravel integration for HashiCorp Vault
PhpPlaisio: Config Vault
PHP Library Serverless
Content Management System for Laravel
PhpPlaisio: Config Vault Commands
PhpPlaisio: Plain File Config Vault
统计信息
- 总下载量: 235
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2018-07-13